BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [knn].')
alexgsslbmz opened this issue · 3 comments
Something is wrong with the Hybrid Search query:
results = es.search(
query={
"bool": {
**search_query,
**filters
}
},
knn={
"field": "embedding",
"query_vector": es.get_embedding(parsed_query),
"k": 10,
"num_candidates": 50,
},
rank={"rrf": {}},
aggs={
"category-agg": {
"terms": {
"field": "category.keyword",
}
},
"year-agg": {
"date_histogram": {
"field": "updated_at",
"calendar_interval": "year",
"format": "yyyy",
},
},
},
size=5,
from_=from_,
)
I get this error:
BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [knn].')
If I delete the knn Param I get this error:
BadRequestError(400, 'parsing_exception', 'Unknown key for a START_OBJECT in [rank].')
If I also delete also rank Param it works.
Can someone help me please?
@alexgsslbmz what version of the Elasticsearch Python client are you using? You can find it in the output of the pip freeze
command. The Search Tutorial is built for 8.11 or newer versions. I suspect you are using an older client version. Also you should make sure that the client version matches the version of the Elasticsearch stack that you are using.
Hi @miguelgrinberg , thank you for your reply, I use elasticsearch Pythin client:
elastic-transport==8.12.0
elasticsearch==8.12.0
And elasticsearch:
'version': {'build_date': '2024-02-02T12:04:59.691750271Z',
'build_flavor': 'default',
'build_hash': '8682172c2130b9a411b1bd5ff37c9792367de6b0',
'build_snapshot': False,
'build_type': 'deb',
'lucene_version': '8.11.1',
'minimum_index_compatibility_version': '6.0.0-beta1',
'minimum_wire_compatibility_version': '6.8.0',
'number': '7.17.18'}}
The elasticsearch Server Version was too old.