Reputation: 313
Using ElasticSearch 8.7, try to run below query on searching multiple knn fields based the documentation but get error as title (https://www.elastic.co/guide/en/elasticsearch/reference/8.7/knn-search.html#_search_multiple_knn_fields)
Does any one know why?
q = {
"query": {
"match": {
"context": {
"query": "mountain lake",
"boost": 0.5
}
}
},
"knn": [{
"field": "sb_emb",
"query_vector": vector_1,
"k": 5,
"num_candidates": 50,
"boost": 0.3
},
{
"field": "ins_emb",
"query_vector": vector_2,
"k": 10,
"num_candidates": 10,
"boost": 0.5
}],
"size": 10
}
es_client = Elasticsearch(
"https://localhost:9200",
verify_certs=False,
basic_auth=(ELASTICSEARCH_USER_LOCAL,
ELASTICSEARCH_PASSWORD_LOCAL)
es_client.search(body=knn_query_sb, index=INDEX_NAME)
My mapping:
{
"properties": {
"context": {
"type": "text",
"analyzer": "standard",
"fields": {
"keyword_field": {
"type": "keyword"
}
}
},
"sb_emb": {
"type": "dense_vector",
"dims": dim_sbert,
"index": True,
"similarity": "cosine",
"index_options": {"type": "hnsw", "m": 32, "ef_construction": 128 }
},
"ins_emb": {
"type": "dense_vector",
"dims": dim_instruct,
"index": True,
"similarity": "cosine",
"index_options": {"type": "hnsw", "m": 32, "ef_construction": 128 }
},
"doc_location": {
"type": "text"
}
}
}
tried the python client and got the same error.
Upvotes: 0
Views: 547
Reputation: 313
This is an issue with the elasticsearch-py, the python package (8.8 released) does not support this. Update to 8.10 (use github main branch) solved the problem.
Upvotes: 0