PHP SDK
The official PHP SDK for brinicle provides an idiomatic HTTP client for communicating with the brinicle vector engine server. It requires PHP 8.1+ and uses Guzzle HTTP under the hood.Installation
Quick Start
Configuration
Constructor Options
config array is passed directly to the Guzzle HTTP client constructor, so any Guzzle-compatible option is supported.
API Reference
healthCheck
Check if the server is running and get the number of loaded indexes.createIndex
Create a new vector index on the server.listIndexes
Get a list of all loaded indexes.deleteIndex
Close or destroy an index.getIndexStatus
Check the status of an index.loadIndex
Load an existing index from disk.init
Initialize an ingest session.ingest
Ingest a single vector.ingestBatch
Batch ingest using the binary protocol for maximum throughput.finalize
Complete an ingest session.deleteItems
Remove items from an index.rebuild
Perform a compact rebuild.search
Search for nearest neighbors.optimize
Optimize the HNSW graph.ItemSearch
The ItemSearch API enables structured search over items with lexical fields, combining vector similarity with metadata filtering. Unlike the basic vector search which operates on raw embeddings, ItemSearch lets you ingest items with human-readable fields such as titles, descriptions, and categories, then perform filtered searches that combine full-text matching with vector similarity. This makes it ideal for product catalogs, document collections, and any dataset where you need to search by both content and structured attributes. Each item index is backed by its own vector index, so you still benefit from brinicle’s high-performance HNSW graph for similarity lookups. The difference is that ItemSearch adds a lexical configuration layer that controls how text fields are tokenized and matched, allowing you to fine-tune relevance for your specific domain.createItemIndex
Create a new item search index with an optional lexical configuration. ThelexicalConfig parameter controls how text fields are analyzed during ingestion and search — you can specify which fields are searchable, how they are tokenized (e.g., word boundaries, lowercasing), and whether stemming or stop-word removal should be applied. If omitted, a default configuration is used that treats all text fields as searchable with standard tokenization.
initItemIngest
Initialize an ingest session for an item index. This works identically to the vector engine’sinit method, accepting a mode of 'build', 'insert', or 'upsert'. You must call this before ingesting any items, and you must call finalize after all items have been ingested. The build mode creates a fresh index from scratch, while insert and upsert modes allow you to add or update items in an existing index.
ingestItem
Ingest a single item with its external ID, vector, and associated metadata fields. The item fields are arbitrary key-value pairs that will be indexed according to the lexical configuration specified when the index was created. Fields not listed in thesearchableFields of the LexicalConfig are stored but not indexed for text search. The vector must match the dimension specified during index creation.
searchItems
Search for items using a combination of vector similarity and structured filters. Thequery parameter provides the text query which is matched against the searchable fields defined in the lexical configuration. The filters parameter accepts structured conditions that narrow results by exact field values or ranges. You can control the number of results with k and the search beam width with efs for fine-grained recall/latency trade-offs.
deleteItemIndex
Delete or close an item search index. When called withdestroy: false (the default), the index is closed but its data remains on disk and can be reloaded later. When called with destroy: true, the index and all its data are permanently removed. This method is identical in behavior to deleteIndex but operates on item search indexes specifically.
getItemIndexStatus
Check the status of an item search index. Returns the index name, dimension, whether the HNSW graph has been built, and whether a rebuild is needed after recent ingestions. This is useful for monitoring the health of your indexes and determining when a rebuild or optimization might be necessary.LexicalConfig Model
TheLexicalConfig model controls how text fields are analyzed and indexed for full-text search within an item index. Proper configuration of the lexical analyzer is critical for search quality — for example, enabling stemming allows searches for “running” to match documents containing “run”, while stop-word removal prevents common words like “the” and “and” from polluting the index.
| Field | Type | Default | Description |
|---|---|---|---|
searchableFields | string[] | [] | Fields that should be indexed for text search |
tokenizer | string | 'standard' | Tokenizer to use (standard, whitespace, ngram) |
lowercase | bool | true | Whether to lowercase all tokens |
stem | bool | false | Whether to apply stemming to tokens |
removeStopWords | bool | false | Whether to remove common stop words |
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 search boxes, tag suggestion, and any interface where users type partial queries and expect instant results. Unlike ItemSearch which combines vector similarity with text matching, Autocomplete focuses on sub-millisecond prefix lookups over string keys. Each autocomplete index stores a set of string keys and their associated vectors. When a user types a partial query, the engine searches for keys that begin with the typed prefix and returns the closest matches ranked by vector similarity. This allows you to build autocomplete experiences that are both fast and semantically relevant — for example, typing “iph” could suggest “iPhone 15 Pro Max” based on both the prefix match and the semantic proximity to other electronics products.createAutocompleteIndex
Create a new autocomplete index with an optional autocomplete configuration. TheautocompleteConfig parameter controls how suggestions are matched and ranked — for example, you can set the minimum prefix length before suggestions are returned, the maximum number of suggestions, and whether to apply fuzzy matching for typo tolerance. If omitted, sensible defaults are used that work well for most use cases.
initAutocompleteIngest
Initialize an ingest session for an autocomplete index. Like the vector engine’sinit method, this must be called before ingesting any autocomplete entries. The mode controls whether you are building a new index from scratch or adding entries to an existing one. After ingesting all entries, you must call finalize to commit the data and build the prefix index.
ingestAutocomplete
Ingest a single autocomplete entry with its key string and associated vector. The key is the string that users will type as a prefix — for example, a product name like “iPhone 15 Pro Max”. The vector provides the semantic representation used to rank suggestions when multiple prefix matches exist. Keys should be lowercase if theAutocompleteConfig specifies lowercase: true, as the engine will not automatically normalize keys during ingestion.
searchAutocomplete
Search for autocomplete suggestions matching a given prefix. Thequery parameter is the partial string typed by the user, and the k parameter controls how many suggestions to return. Results are ranked by a combination of prefix match quality and vector similarity, ensuring that the most relevant suggestions appear first. This method is designed for sub-millisecond response times, making it suitable for interactive type-ahead interfaces.
deleteAutocompleteIndex
Delete or close an autocomplete index. When called withdestroy: false (the default), the index is closed but its data remains on disk. When called with destroy: true, the index and all associated data are permanently removed from disk. Use this method to clean up indexes that are no longer needed or to force a full rebuild by destroying and recreating an index.
getAutocompleteIndexStatus
Check the status of an autocomplete index. Returns the index name, vector dimension, whether the prefix index has been built, and whether a rebuild is needed after recent ingestions. Monitoring index status is important for autocomplete indexes because the prefix index must be rebuilt after ingestion to reflect new entries.AutocompleteConfig Model
TheAutocompleteConfig model controls how the autocomplete engine matches prefixes and ranks suggestions. Tuning these parameters allows you to balance between suggestion speed and quality — for example, setting a higher minPrefixLength reduces the number of candidates the engine must evaluate for very short queries, while enabling fuzzyMatch allows the engine to suggest entries even when the user makes a typo.
| Field | Type | Default | Description |
|---|---|---|---|
minPrefixLength | int | 1 | Minimum characters before suggestions are returned |
maxSuggestions | int | 10 | Maximum number of suggestions per query |
fuzzyMatch | bool | false | Whether to enable fuzzy matching for typos |
fuzzyDistance | int | 2 | Maximum edit distance for fuzzy matches |