I have installed Elasticsearch 7.17.17 version. i am doing semantic search, but at final search it give me the error which is give below:BadRequestError(400, 'illegal_argument_exception', 'Invalid type: expecting [_doc] but got [_knn_search]')

BadRequestError(400, 'illegal_argument_exception', 'Invalid type: expecting [_doc] but got [_knn_search]')

input_keyword = "Blue Shoes"
vector_of_input_keyword = model.encode(input_keyword)

query = {
"field" : "DescriptionVector",
"query_vector" : vector_of_input_keyword,
"k" : 2,
"num_candidates" : 500,

res = es.knn_search(index="all_products", knn=query , source=["ProductName","Description"])
this is my final query

When looking at the docs it is important to make sure you are looking at the right version. As far as I can see the _knn_search API does not exist for Elasticsearch 7.17. As this is an area where a lot of development and changes are taking place I would recommend you upgrade to the latest 8.x version in order to ensure you do not develop a solution based on a changing or deprecating API.

Which client and version are you using?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.