Enhancing Semantic Search (Text to Vector) in Solr

With Solr 9.9.0, you get end-to-end semantic vector search built directly into Solr. By using a service like Hugging Face or Cohere, you can configure your model within Solr and get semantic search up and running quickly.

Vectorization, for both indexing and search, happens entirely within Solr, so there's no need to manually handle vectors anymore.

Despite this being a big step forward, you are still limited to third-party language models hosted in the cloud from a few supported providers. This might be suitable to get up and running quickly, but it has a number of drawbacks:

I've expanded on what Solr provides out of the box, allowing you to easily connect your custom model running on any endpoint. On top of that, I've added two new features that make vector search even more powerful.

1. Support for multiple fields

You can combine multiple text fields into a single vector representation — for example, product name, product description, and marketing text can all be combined into one vector. Simply configure the additional fields you want to include in your vector.

2. Lazy vectorization

When updating a document in Solr, the new vector for that document is only recreated if the content of a field used for the vector has changed. This is achieved by fetching the existing document within the update process and checking whether any field used in the vector embedding has actually changed. The vector is only regenerated when one of the relevant fields has changed, which minimizes the expensive creation of vectors.

More details, including a step-by-step guide on how to configure this in Solr, can be found on GitHub. Feel free to check it out.

Code on GitHub
github.com/renatoh/solrCustomEmbeddingModel
Custom embedding model for Solr, with multi-field vectors and lazy vectorization.
← Back to all articles