Aller au contenu

omnisearch/typesense Référence de l’API

Étage
Fournisseur · Omnisearch
Version
1.x
Suite de conformité
branchée, CI rouge
Vérifié en réel
Vérifié en partie
Licence
MIT
composer require omnisearch/typesense:1.x-dev

Lue dans les fichiers PHP du paquet au commit fa612a42da97 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.

Omnisearch\Typesense

  • Mapping class

    An index's metadata as glitchr/typesense-bundle describes a collection: the very array an entry of its `typesense.mappings` is once its configuration tree has filled the defaults - so the bundle makes the same TypesenseMetadata, the same schema and the same documents as if its configuration had declared the collection.

    2 methods · 3 constants

  • TypesenseDriver class

    Omnisearch's driver for Typesense, over glitchr/typesense-bundle: an index is one of the bundle's collections (its discriminator sub-collections with it), an object becomes its document by the bundle's transformer, a Request the bundle's Query, the bundle's Response a Response. Nothing of the bundle is written again here.

    15 methods

  • TypesenseDriverFactory class

    The "typesense" engine. Two ways:

    3 methods

Omnisearch\Typesense\Bridge\Symfony

  • TypesenseHost class

    In a Symfony application with glitchr/typesense-bundle, the indexes a "typesense" connection's classes declare by omnisearch's attributes become the bundle's mappings, prepended to its configuration: the bundle creates the collections (typesense:create), indexes them on Doctrine's events and imports them (typesense:action, typesense:update), exactly as for those its configuration declares; omnisearch searches through it.

    2 methods

Omnisearch\Typesense

Mapping class

final class Mapping Mapping.php:23

An index's metadata as glitchr/typesense-bundle describes a collection: the very array an entry of its typesense.mappings is once its configuration tree has filled the defaults - so the bundle makes the same TypesenseMetadata, the same schema and the same documents as if its configuration had declared the collection.

Omnisearch's types become Typesense's (int: int32, bigint: int64, the lists alike; datetime stays the bundle's datetime, a timestamp in int64). A field's sort, optional and locale, and its options under "typesense" (or flat), are the bundle's field options, sent with the schema; the index's options are the collection's default_sorting_field, token_separators and symbols_to_index.

const TYPES = [Type::STRING => 'string', Type::STRINGS => 'string[]', Type::INT => 'int32', Type::INTS => 'int32[]', Type::BIGINT => 'int64', Type::FLOAT => 'float', Type:…
const TOKEN_SEPARATORS = ['+', '-', '@', '.', ' ']

The bundle's defaults (its configuration tree's).

const SYMBOLS_TO_INDEX = ['+']

Mapping::toTypesense()

public static function toTypesense(ClassMetadata $metadata, string $connection = 'default'): array
$connection

the bundle's connection the collection lives on

Mapping::field()

public static function field(FieldMetadata $field): array

TypesenseDriver class

final class TypesenseDriver implements Driver TypesenseDriver.php:44

Omnisearch's driver for Typesense, over glitchr/typesense-bundle: an index is one of the bundle's collections (its discriminator sub-collections with it), an object becomes its document by the bundle's transformer, a Request the bundle's Query, the bundle's Response a Response. Nothing of the bundle is written again here.

In a Symfony application with the bundle, the collections are the bundle's own (TypesenseHost declared them); elsewhere they are made here on first use from the metadata.

A server that cannot be reached is caught by the PSR-18 interfaces (Psr\Http\Client\ClientExceptionInterface), whatever client php-http's discovery gave typesense-php: Symfony's Psr18Client throws its Psr18NetworkException, which the bundle (catching HTTPlug's exception) lets through. A search then answers a failed Response (503), a write throws a DriverException (503).

TypesenseDriver::__construct()

public function __construct(readonly TypesenseManager $manager, readonly string $connection, readonly ?TransformerInterface $transformer = null, readonly string $prefix = '')

TypesenseDriver::manager()

public function manager(): TypesenseManager

TypesenseDriver::collection()

public function collection(ClassMetadata $metadata): TypesenseCollection

The bundle's collection of an index, made and registered when the bundle has none.

Throws

InvalidConfigException when the bundle has none and this driver no transformer to make it

TypesenseDriver::collections()

public function collections(ClassMetadata $metadata): array
Returns

the index's collection and its sub-collections, by name

TypesenseDriver::create()

public function create(ClassMetadata $metadata): void

TypesenseDriver::drop()

public function drop(ClassMetadata $metadata): void

TypesenseDriver::schema()

public function schema(ClassMetadata $metadata): array

TypesenseDriver::schemas()

public function schemas(ClassMetadata $metadata): array
Returns

the schemas of the index's collection and sub-collections, by name on the server

TypesenseDriver::schemaOf()

public static function schemaOf(TypesenseCollection $collection): array

What TypesenseCollection::create() sends.

TypesenseDriver::index()

public function index(ClassMetadata $metadata, object ...$objects): void

TypesenseDriver::remove()

public function remove(ClassMetadata $metadata, string ...$ids): void
public function search(ClassMetadata $metadata, Request $request): Response

TypesenseDriver::query()

public static function query(ClassMetadata $metadata, Request $request): Query

A Request as the bundle's Query.

TypesenseDriver::filter()

public static function filter(Filter $filter): string

A Filter in Typesense's filter_by syntax.

TypesenseDriver::response()

public static function response(TypesenseResponse $response): Response

The bundle's Response as a Response.

TypesenseDriverFactory class

final class TypesenseDriverFactory implements DriverFactory TypesenseDriverFactory.php:25

The "typesense" engine. Two ways:

  • over the bundle's manager (a Symfony application with glitchr/typesense-bundle: autowired), the connection named by the connection option (default "default"), its collections the bundle's;
  • on its own, from the options url (or scheme, host, port), secret, prefix (put in front of every collection's name on the server) and options (the client's): a manager of its own, the collections made from the metadata, documents made by the bundle's transformer on Doctrine's $objectManager.

TypesenseDriverFactory::__construct()

public function __construct(readonly ?TypesenseManager $manager = null, readonly ?ObjectManager $objectManager = null)

TypesenseDriverFactory::name()

public function name(): string

TypesenseDriverFactory::create()

public function create(array $options): Driver

Omnisearch\Typesense\Bridge\Symfony

TypesenseHost class

final class TypesenseHost implements Host TypesenseHost.php:18

In a Symfony application with glitchr/typesense-bundle, the indexes a "typesense" connection's classes declare by omnisearch's attributes become the bundle's mappings, prepended to its configuration: the bundle creates the collections (typesense:create), indexes them on Doctrine's events and imports them (typesense:action, typesense:update), exactly as for those its configuration declares; omnisearch searches through it.

TypesenseHost::hosts()

public static function hosts(ContainerBuilder $builder): bool

TypesenseHost::prepend()

public static function prepend(ContainerBuilder $builder, string $connection, array $options, array $metadata): void