Laravel SDK
The official Laravel SDK provides seamless integration with the brinicle vector engine through a Service Provider, Facade, configurable connections, and Artisan commands.Installation
Configuration
Environment Variables
Add the following to your.env file:
Publish Config
Publish the configuration file for customization:config/brinicle.php:
Multiple Connections
For applications that need to connect to multiple brinicle servers, add additional connections:Usage
Via Facade
TheBrinicle facade provides a clean, static-like interface to the underlying client:
Via Dependency Injection
Inject the client directly into your services for better testability:Via Manager
TheBrinicleManager provides connection management:
ItemSearch
The ItemSearch API provides structured search over items with lexical fields, combining vector similarity with metadata filtering. This is especially useful in Laravel applications that manage product catalogs, article repositories, or any Eloquent model collection where you need to search by both content and structured attributes. The Laravel facade exposes all ItemSearch methods with the same clean interface as the vector engine methods.Creating an Item Index
Use theBrinicle facade to create an item search index with a lexical configuration. The lexical configuration determines which fields are searchable and how text is analyzed. You can define the configuration inline or store it in your config/brinicle.php file for reuse across multiple indexes.
Ingesting Items
Initialize an ingest session, then ingest items with their vectors and metadata fields. Each item consists of an external ID, a vector matching the index dimension, and an associative array of string fields. Fields listed in thesearchableFields of your LexicalConfig will be indexed for full-text search, while other fields are stored but not searchable. After all items are ingested, call finalize to build the index.
Searching Items
Search for items using a text query with optional structured filters. ThesearchItems method combines full-text matching against your searchable fields with vector similarity, returning results ranked by relevance. You can narrow results using ItemSearchFilters to require certain field values or exclude others.
Deleting and Monitoring Item Indexes
You can close or permanently destroy item indexes, and check their status at any time. Closing an index preserves its data on disk for later reloading, while destroying it permanently removes all data. The status check returns the index name, dimension, and whether a rebuild is needed after recent ingestions.Autocomplete
The Autocomplete API provides prefix-based search for type-ahead and suggestion use cases. Autocomplete indexes are optimized for fast prefix matching, making them ideal for building search suggestion dropdowns, tag autocomplete fields, and any interface where users type partial queries and expect instant results. In Laravel, you can use the facade or dependency injection to manage autocomplete indexes alongside your vector and item search indexes.Creating an Autocomplete Index
Create an autocomplete index with an optional configuration that controls suggestion matching and ranking behavior. The configuration lets you set the minimum prefix length before suggestions appear, the maximum number of suggestions returned, and whether fuzzy matching is enabled for typo tolerance. These settings can be tuned per-index depending on the use case.Ingesting Autocomplete Entries
Initialize an autocomplete ingest session, then ingest entries consisting of a key string and its associated vector. The key is the text that users will search for by prefix — for example, a product name. The vector provides the semantic representation used to rank suggestions when multiple prefix matches are found. After all entries are ingested, callfinalize to commit the data and build the prefix index.
Searching Autocomplete Suggestions
Search for autocomplete suggestions by providing a partial query string. Results are ranked by a combination of prefix match quality and vector similarity, ensuring that the most relevant suggestions appear first. The method is designed for sub-millisecond response times, making it suitable for interactive type-ahead interfaces in your Laravel front-end.Deleting and Monitoring Autocomplete Indexes
Manage autocomplete indexes by closing or destroying them, and checking their status. The status check returns the index name, dimension, whether the prefix index is built, and whether a rebuild is needed. This is particularly important for autocomplete indexes because the prefix index must be rebuilt after ingestion to reflect new entries.Artisan Commands
The Laravel SDK includes Artisan commands for common operations across vector, item search, and autocomplete indexes:Create Index
List Indexes
Index Status
Delete Index
--connection= option for multi-connection setups:
Create Item Index
Create a new item search index with lexical configuration for full-text search over structured items. The--searchable-fields option accepts a comma-separated list of field names that should be indexed for text search. Additional options control the lexical analyzer behavior including tokenization, stemming, and stop-word removal.
Item Search
Search for items in an item search index using a text query. The command prints the matching items with their IDs, scores, and matched fields. You can apply structured filters using the--must and --must-not options to narrow results by field values.
Item Ingest
Ingest items into an item search index from a JSON file. The file should contain an array of objects, each with anid, vector, and fields key. This is useful for bulk-loading product catalogs or document collections from Eloquent model exports or external data sources.
Create Autocomplete Index
Create a new autocomplete index for prefix-based suggestion search. The--min-prefix-length option sets how many characters a user must type before suggestions appear, and --fuzzy-match enables typo tolerance with a configurable edit distance.
Autocomplete Search
Search for autocomplete suggestions matching a prefix query. This command is useful for testing your autocomplete indexes from the command line or for building CLI-based search tools.Autocomplete Ingest
Ingest autocomplete entries from a JSON file. Each entry should have akey (the suggestion text) and a vector (the semantic representation). This command handles the full ingest lifecycle including initialization and finalization.