【发布时间】:2022-11-24 07:14:33
【问题描述】:
我的查询显示错误 BadRequestError: BadRequestError(400, 'x_content_parse_exception', '[1:34] [bool] failed to parse field [must]')
我尝试删除 [] 但这也没有用。我觉得我搞砸了这个查询中的 KNN 部分。请帮忙!
helper_token = Tokenizer()
INPUT = input("Enter the Input Query ")
token_vector = helper_token.get_token(INPUT)
query ={
"size":50,
"_source": "Title",
"query":{
"bool":{
"must":[
{
"knn":{
"vectors":{
"vector":token_vector,
"k":20
}
}
}
]
}
}
}
es = Elasticsearch(timeout=600,hosts=os.getenv(ENDPOINT),cloud_id="PVT",http_auth=("elastic", PASSWORD))
res = es.search(index='posting',body=query)
title = [x['_source'] for x in res['hits']['hits']]
title
【问题讨论】:
标签: elasticsearch elastic-stack