-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove unnecessary override code #2695
Remove unnecessary override code #2695
Conversation
A documentation preview will be available soon. Request a new doc build by commenting
If your PR continues to fail for an unknown reason, the doc build pipeline may be broken. Elastic employees can check the pipeline status here. |
Wouldn't your problem be addressed if you move the text field to the vector store? strategy = DenseVectorStrategy(
model_id=".multilingual-e5-small_linux-x86_64",
hybrid=True,
)
store = ElasticsearchStore(
es_connection=elasticsearch_client,
index_name=INDEX,
vector_query_field="content_semantic.inference.chunks.embeddings",
query_field="title",
strategy=strategy,
) And also, note that So I think you need to first of all decide if you want to use Unfortunately this way these constructors were designed is extremely convoluted, which is really the source of the problem you are having. Your fix addresses the way in which you are using this integration but does not do much to improve the overall design, in fact you may not have realized that you are searching two different fields. |
Hi @miguelgrinberg , thanks for your comment. It is understood. Currently I configured with the same way with your suggestion. Below is just my comments. If I set My first intention is Second, if we can set the FYI, here is my (partial) mapping
|
Right, so you are taking advantage of a design flaw in these classes, and running a hybrid search that uses different fields for the BM25 and kNN portions, which as far as I can see is not an intended usage. You are suggesting that If you wanted to keep doing this, then you do not need to change anything, just do this: strategy = DenseVectorStrategy(
model_id=".multilingual-e5-small_linux-x86_64",
hybrid=True,
)
store = ElasticsearchStore(
es_connection=elasticsearch_client,
index_name=INDEX,
vector_query_field="content_semantic.inference.chunks.embeddings",
query_field="content",
strategy=strategy,
)
strategy.text_field = 'title' # override the field used in the kNN search |
@miguelgrinberg |
I tested below code to test DenseVectorStrategy:
But I realized
text_field="title"
parameter in the DenseVectorStrategy constructor doesn't affect since it is overridded in:https://github.com/elastic/elasticsearch-py/blob/main/elasticsearch/helpers/vectorstore/_sync/vectorstore.py#L83-L86
And also there is no
vector_field
in all of strategy classes.This PR intends to:
text_field
field only when it is not provided as part of constructorif hasattr(retrieval_strategy, "vector_field")
is always False