Reputation: 45
I am getting the error:
BadRequestError(400, 'x_content_parse_exception', '[1:34] [bool] failed to parse field [must]')
following is my source code:
query ={
"size":50,
"_source": "Title",
"query":{
"bool":{
"must":[
{
"knn":{
"vectors":{
"vector":token_vector,
"k":20
}
}
}
]
}
}
}
res = es.search(index='posting', body=query)
I am using the latest version of elasticsearch (8.5.2)
I also searched for similar questions raised before but unfortunately, I could not get any answers satisfying my question.
Upvotes: 0
Views: 2640
Reputation: 3271
Knn is parameter search query. Try like this
{
"size":50,
"_source":"Title",
"query":{
"bool":{
"must":[
//other clausule
]
}
},
"knn":{
"field": "FIELD_VECTOR",
"query_vector": "YOUR_VECTOR",
"k": 10,
"num_candidates": 100
}
}
Upvotes: 0