Search by

geekybones / typesense-bundle

manojx

Symfony bundle for Typesense: attribute mapping, zero-downtime reindexing, Doctrine sync, smart and semantic search, query parsing and query suggestions.

Package info

github.com/geekybones/typesense-bundle

Type:symfony-bundle

pkg:composer/geekybones/typesense-bundle

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-10-27 10:50 UTC

This package is auto-updated.

Last update: 2026-10-27 10:52:34 UTC


README

A bundle to use Typesense in a Symfony app. It covers the basics, and adds extra features on top.

The basics

  • Map Doctrine entities to collections with attributes
  • Keyword search, filters, sorting and facets
  • Load results as Doctrine entities

The extras

  • Zero-downtime reindex. A new collection is built, then swapped in.
  • Live sync. The index follows your database on every save and delete.
  • Enrichers. Add data that is not on the entity: fixed text, other tables, grouped options.
  • Smart search. Keyword first, then search by meaning when keywords are not enough.
  • Recommendations. Items like one item, or like the best hit of a search.
  • Query parsing. "wool coats with gold buttons" becomes text plus a filter.
  • Query suggestions. Complete what people type from popular and seeded searches.
  • Stores and tenants. Keep many stores apart in one collection (guide).
  • Fast repeats. Add use_cache and Typesense answers repeated searches from its cache.
  • Multi search. Run several searches in one request.
  • Assistant ready. Feed a shopping or chat assistant (guide).
  • Easy to extend. Replace the router, the parser or the value source with your own class.

Quick start

1. Install

Need a Typesense server first? See the official Typesense install guide or our Installation.

composer require geekybones/typesense-bundle
// config/bundles.php
return [
    GeekyBones\TypesenseBundle\TypesenseBundle::class => ['all' => true],
];
# config/packages/typesense.yaml
typesense:
    api_key: '%env(TYPESENSE_API_KEY)%'
    nodes:
        - { host: '%env(TYPESENSE_HOST)%' }   # http://localhost:8108

2. Map an entity

use GeekyBones\TypesenseBundle\Attribute\TypesenseCollection;
use GeekyBones\TypesenseBundle\Attribute\TypesenseField;

#[TypesenseCollection(name: 'products')]
#[ORM\Entity]
class Product
{
    #[ORM\Id, ORM\GeneratedValue, ORM\Column]
    private ?int $id = null;

    #[ORM\Column]
    #[TypesenseField(queryBy: true, weight: 3)]
    private string $name;

    #[ORM\Column]
    #[TypesenseField(facet: true)]
    private ?string $brand = null;

    #[ORM\Column]
    #[TypesenseField(sort: true)]
    private int $price = 0;
}

3. Index and search

bin/console typesense:reindex products
use GeekyBones\TypesenseBundle\Contract\SearcherInterface;

final class SearchController
{
    public function __construct(private SearcherInterface $searcher) {}

    public function __invoke(string $q): array
    {
        $result = $this->searcher->smartSearch(Product::class, $q);

        return ['found' => $result->found, 'items' => $result->documents()];
    }
}

After this, saving or deleting a Product updates the index for you.

Guides

Guide Learn how to
Installation Install the bundle and run Typesense
Configuration Set every option in typesense.yaml
Mapping Turn entities into collections
Indexing Reindex, keep the index in sync
Enrichers Add data that is not on the entity
Searching Search, filter, sort, load entities
Semantic search Find results by meaning
Query parsing Turn "wool coats with gold buttons" into a filter
Query suggestions Complete what people type
Stores and tenants Keep many stores in one collection
Shopping assistant Build a chat assistant, with Typesense conversational search or your own code
Testing Test your code and the bundle
Troubleshooting Fix common problems

Commands

Command What it does
typesense:reindex [collection] Rebuild the index from the database
typesense:suggestions:setup [collection] Create the suggestions collection
typesense:query:parse <collection> "<query>" Show what the query parser finds

Services you can inject

Type Use it to
SearcherInterface Search
IndexerInterface Save or delete one entity in the index
ReindexerInterface Rebuild a collection
SchemaBuilder Get the schema a reindex would create
QuerySuggesterInterface Complete and seed search phrases
QueryRouterInterface Decide when to search by meaning
VocabularyProviderInterface Read or clear the values the query parser knows
Typesense\Client Use the official client for anything else

Requirements

License

MIT. See LICENSE.

Made by GeekyBones. Source and issues: github.com/geekybones/typesense-bundle.