Skip to content

Querying the Same Index with VectorStore #2658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
omriel1 opened this issue Sep 15, 2024 · 2 comments
Closed

Querying the Same Index with VectorStore #2658

omriel1 opened this issue Sep 15, 2024 · 2 comments
Labels
Area: Client Manually written code that fits in no other area Category: Question

Comments

@omriel1
Copy link

omriel1 commented Sep 15, 2024

Hi!
I’m wondering what is the correct approach for querying the same index using a VectorStore.

For example, assuming I've created an index with DenseVectorStrategy I can query it using the search method, but it'll strictly perform what was defined in the implemented es_query (knn search or hybrid search if specified).

However, I have a couple of scenarios I’d like to address:

  1. How can I query the same index using only BM25 (i.e., without invoking the vector search capabilities)?
  2. Is it possible to perform hybrid searches on the same index but vary the merging strategy (e.g., using RRF or applying different boosting scoring) between searches?

Currently, the only option I’ve found is to instantiate a new VectorStore object for each query configuration. This feels inefficient, and I’m wondering if there’s a better way to handle these types of queries without recreating the VectorStore each time.

Thanks!

@miguelgrinberg
Copy link
Contributor

Hi! The VectorStore.search() method allows you to pass a custom_query argument with a callable. Your function will be called with the Elasticsearch query, to give you the option to make changes to it before the query is executed. That should allow you to issue queries that are different than the one that corresponds to the strategy you selected.

@miguelgrinberg miguelgrinberg added Area: Client Manually written code that fits in no other area Category: Question labels Sep 23, 2024
@omriel1
Copy link
Author

omriel1 commented Sep 25, 2024

Thank you!

@omriel1 omriel1 closed this as completed Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Client Manually written code that fits in no other area Category: Question
Projects
None yet
Development

No branches or pull requests

2 participants