Setting up¶
Requirements¶
- Drupal 10.3 or 11.
- The AI module 1.2 or later, with AI Search, and Key.
- Solr 9.6 or later. Solr 10 adds quantized vectors (scalar and binary), which hold several times as many vectors in the same memory.
-
A core for the vectors, made from Solr's
_defaultconfigset. For example, in Docker:docker run -d --name solr -p 8983:8983 solr:10.0.0 solr-precreate vectorsThe provider adds its vector fields and their types through the Schema API, and turns off the configset's guessing of new fields.
To run Solr on a server of its own, see Solr on DigitalOcean.
Installing¶
composer require 'drupal/ai_vdb_provider_solr:^1.0@alpha'
drush pm:install ai_vdb_provider_solr
Connecting to Solr¶
At Configuration » AI » Vector Database Providers » Solr Configuration
(/admin/config/ai/vdb_providers/solr):
| Setting | What to give |
|---|---|
| Scheme | http, or https behind TLS. |
| Host | The Solr server's host name, without the scheme. |
| Port | 8983 for Solr itself, 443 behind an HTTPS proxy. |
| Path to Solr | The path before /solr/, usually /. |
| Core or collection | The core made for the vectors, such as vectors. |
| User name | For basic authentication; leave empty without it. |
| Password | A Key that holds the basic authentication password. |
| Vector quantization | For new collections: none, scalar or binary. Scalar and binary need Solr 10. |
| Commit within (ms) | How soon indexed chunks become searchable. |
| Timeout (s) | How long each request to Solr may take. |
The form pings the core before it saves. The core's address is the scheme,
host and port, then the path, /solr/ and the core: with a path of /,
https://solr.example.com:443/solr/vectors.
The same settings can be set with Drush:
drush config:set ai_vdb_provider_solr.settings host solr.example.com -y
Creating a collection¶
- At Configuration » Search and metadata » Search API, add a server.
- Choose the AI Search backend and an Embeddings Engine.
- Choose Apache Solr as the Vector Database.
- Under Vector Database Configuration, name a Collection and choose the Similarity Metric.
- Leave Include raw embedding vector in results off: the provider indexes vectors without storing them, so it cannot return them.
- Save the server.
The collection is created in the core when the server is saved, or, for a server imported from configuration, when it first indexes. A collection's dimension, similarity and quantization are fixed when it is created.