Problem/Motivation
OpenSearch supports neural search using text embeddings: https://opensearch.org/docs/latest/search-plugins/neural-search/
The purpose of this issue is to add neural search capabilities to this module.
Proposed resolution
OpenSearch can generate text embeddings for you, but we decided to do it on the Drupal side instead. The main reason is to allow us to use AI models that are not supported by OpenSearch.
Remaining tasks
- Create neural backend plugin type
- Implement ollama backend plugin
- Implement OpenAI backend plugin
- Generate text embeddings during indexing and add the vector to the indexed data
- Create views filter for neural search (which generates the vector for the search query and queries OpenSearch based on that)
- Create configuration UIs
- Add test coverage
Issue fork search_api_opensearch-3472769
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
slashrsm commentedComment #3
slashrsm commentedStill work in progress, but the idexing side of things work.
Comment #5
kim.pepperThanks Janez. Looks like a great start. Besides the linting errors, I can see there are still a lot of hard coded values, and we're missing tests. I know it's a complex area, but it would be good to have some basic docs on setup and links for further info.
Comment #6
acbramley commentedQuick n dirty review for now as this is obviously still WIP - great to see movement in this area though!
Comment #7
slashrsm commentedComment #9
slashrsm commentedAfter watching Driesnote and looking into AI module a bit I realized that we are basically re-implementing their provider plugins here. In order to avoid that I decided to depend on the AI module for providers. Updated MR assumes/uses #3477750: Provide embeddings vector size , which add vector size function that we rely on.
Comment #10
maximilianmikus commentedI was looking into adding OpenSearch as a vector database provider and I found this issue by chance. I was wondering if it wouldn't be better to put this functionality in its own provider module? I started a project just for that before I found this issue by chance.
Comment #11
damienmckennaFYI the separate provider module has been deprecated in favor of this issue, though the current MR doesn't apply against the 3.x branch.
Comment #12
kim.pepperA recommended approach for vector indexing is an ingest pipeline. I wonder if this issue could be expanded to include support for that?
Comment #14
kim.pepperStarted work on a more integrated approach. At this stage all the MR does is set
index.knn = TRUEwhen creating the index.In order to have knn enabled on an index, we need to set that option when creating the index. We can't change it after.
This meant we needed to refactor the
addIndex()method to not create then update settings, but to pass the settings at creation time. This refactoring could potentially be split out into a separate issue.Comment #15
kim.pepperRan into a bit of an issue with the pipelines. In order to have Opensearch generate the text embeddings, you need to specify text field to embedding field mappings when creating the pipeline. I don't think it would be easy to dynamically create a pipeline like this with search api.
I'm going to check out the https://www.drupal.org/project/ai_vdb_provider_opensearch module to see if the built-in AI Search would work.
Comment #17
mstrelan commentedUpdated the MR so choosing the Text Embedding (Vector) data type creates the field as a text field. Then the field mapper is decorated to create a paired knn_vector field. That will let us dynamically create the ingest pipeline.
Comment #20
kim.pepperChatting with @mohit_aghera in slack and we have a new approach based on a
semanticfield type in OpenSearch 3.1. This greatly simplifies the amount of work needed to support neural search. See https://docs.opensearch.org/docs/latest/field-types/supported-field-type...There is a bug with remote text embedding models, which was recently fixed and merged but not yet in a release. https://github.com/opensearch-project/neural-search/issues/1426
Comment #22
kim.pepperWe have moved this to it's own project https://www.drupal.org/project/search_api_opensearch_semantic with the latest from MR !107.
Please continue any work over there.
Marking this issue as Fixed to provide contribution credits.
Comment #25
kim.pepperCreated #3540868: Add a BeforeIndexCreateEvent for the new event.