How it stores vectors¶
One core holds every collection¶
Each document names its collection and its kind. One document records a collection's vector field, similarity and dimension, and each chunk is a document of its own. Solr has no databases, so AI Search's database name is not used.
A chunk's id is <collection>/<index_id>:<drupal_long_id>.
Several Search API indexes on one AI Search server share its collection and are kept apart by index id. A search sees only its own index. Clearing an index deletes only its chunks, or only one datasource's when Search API removes a datasource. "Delete all items" keeps the collection and its vector field.
Fields¶
A chunk's text, its Drupal ids and its metadata use the _default
configset's dynamic fields: *_s, *_t, *_ss and *_ds.
- Metadata is kept as strings, and numbers and booleans also as numbers, so filters can compare them.
- The vector field is named for its dimension, similarity and quantization,
such as
vector_1536_cosineorvector_1536_cosine_scalar. - Vectors are indexed but not stored, so the raw vector cannot be returned.
Quantization¶
| Setting | Each dimension | Memory, against none | Solr |
|---|---|---|---|
| None | 32-bit float | all of it | 9.1 or later |
| Scalar | 7 bits | about a quarter | 10 |
| Binary | 1 bit | about a thirty-second | 10 |
The setting applies to collections created after it is changed; an existing collection keeps its vector field. The settings form refuses scalar and binary on a Solr older than 10.
Filters¶
AI Search's conditions become Solr filter queries. Solr applies them before the kNN search, so a filtered search still returns the nearest matches. Solr 9.0 applies them after, which is why the module needs 9.1.
Supported operators: =, <>, IN, NOT IN, <, <=, >, >=,
BETWEEN and NOT BETWEEN.
INandNOT INtake lists of any length, through Solr's terms query parser.- Date conditions take Unix timestamps or date strings.
- A value that a number or date field cannot hold raises an error naming the field, operator and value, instead of failing the search inside Solr.
A search in some languages, such as a Search API query with languages set,
keeps to chunks in them. The language is read from the end of the item id
AI Search stores, such as entity:node/1:en. Items of other datasources have
no language, and count as not specified (und), as in Search API.
Missing collection¶
A search in a collection that does not exist fails with an error instead of finding nothing, so the caller can tell a lost collection from a search with no matches. AI Search prepares the filters before it embeds the search keys, and the check runs then, so the failed search costs no embedding.
Scores¶
Lucene scores cosine and dot product similarity as (1 + s) / 2, and Euclidean distance as 1 / (1 + d²). The provider turns them back into the similarity, or the squared distance, as Milvus returns them, so AI Search's thresholds mean the same.
Grouping¶
When AI Search checks access to each result, it uses a grouped search. The provider asks Solr for the nearest chunks, collapsed to one per item. When the page has fewer distinct items than asked for, it raises topK and searches again, until the page is full or every matching chunk has been considered. So a page of results is a full page of distinct items, each represented by its nearest chunk.
Commits¶
Indexing and deleting both use the Commit within window. Only dropping a collection commits at once.