gpt4 book ai didi

node.js - 具有mongoosastic的Elasticsearch查询

转载 作者:行者123 更新时间:2023-12-03 01:55:21 24 4
gpt4 key购买 nike

我正在尝试这样查询:

Gym.search({
"query" : {
"multi_match": {
"fields": ["multi_field"],
"query": req.query.q,
"fuzziness": "AUTO"
}
}
},
function (err, results) {
if (err) {
return console.log(JSON.stringify(err, null, 4));
}
return console.log(JSON.stringify(results, null, 4));
});

但它返回:

"status": 400, "displayName": "BadRequest", "message": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[PzLsLPHfTMu68AQ94_Af8g][gyms][0]: SearchParseException[[gyms][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][1]: SearchParseException[[gyms][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][2]: SearchParseException[[gyms][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][3]: SearchParseException[[gyms][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }{[PzLsLPHfTMu68AQ94_Af8g][gyms][4]: SearchParseException[[gyms][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\"query\":{\"query\":{\"multi_match\":{\"fields\":[\"multi_field\"],\"query\":\"LCC\",\"fuzziness\":\"AUTO\"}}}}]]]; nested: QueryParsingException[[gyms] No query registered for [query]]; }]"



当我使用CURL时,它可以工作...任何人都知道如何解决它?

最佳答案

尝试这样:

 Gym.search({
"multi_match": {
"fields": ["multi_field"],
"query": req.query.q,
"fuzziness": "AUTO"
}
},
function (err, results) {
if (err) {
return console.log(JSON.stringify(err, null, 4));
}
return console.log(JSON.stringify(results, null, 4));
});

关于node.js - 具有mongoosastic的Elasticsearch查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060865/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com