gpt4 book ai didi

elasticsearch - 在 elasticSearch 中查询时定义分析器

转载 作者:行者123 更新时间:2023-11-29 02:43:11 24 4
gpt4 key购买 nike

我是 elasticsearch 的新手,只需要一些说明:我们可以在查询搜索服务器时定义一个分析器吗?我用“文本”和“字段”查询尝试过,效果很好:

查询:

curl -XPOST http://localhost:9200/test/user/_search? -d '{ "query" : {
"text" : {"_all" : {"query" :"Vaibhav","analyzer" :
"lowercase_keyword" }} } }'

结果:

{"took":144,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.10848885,"hits":{"_index":"test","_type":"user","_id":"1","_score":0.10848885,
"_source" : {
"first_name": "Vaibhav",
"last_name":"saini",
"password":"pwd"

但是当我尝试对术语/前缀/通配符查询做同样的事情时,我得到了异常:

查询:

curl -XPOST http://localhost:9200/test/user/_search? -d '{
"query" : { "term" : {"_all" : {"query" :"Vaibhav","analyzer" :
"lowercase_keyword" }} } }'

结果:

{"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures
{[kws9J6tbQtWCMNKBm3Gpkw][test][4]: SearchParseException[[test][4]:
from[-1],size[-1]: Parse Failure [Failed to parse source
[\n{\n\"query\" : {\n\"term\" : {\"_all\" : {\"query\"
:\"Vaibhav\",\"analyzer\" : \"lowercase_keyword\" }}\n}\n}]]]; nested:
QueryParsingException[[test] [term] query does not support [query]];
}{[kws9J6tbQtWCMNKBm3Gpkw][test][1]: SearchParseException[[test][1]:
from[-1],size[-1]: Parse Failure [Failed to parse source
[\n{\n\"query\" : {\n\"term\" : {\"_all\" : {\"query\"
:\"Vaibhav\",\"analyzer\" : \"lowercase_keyword\" }}\n}\n}]]]; nested:
QueryParsingException[[test] [term] query does not support [query]];
}{[kws9J6tbQtWCMNKBm3Gpkw][test][2]: SearchParseException[[test][2]:
from[-1],size[-1]: Parse Failure [Failed to parse source
[\n{\n\"query\" : {\n\"term\" : {\"_all\" : {\"query\"
:\"Vaibhav\",\"analyzer\" : \"lowercase_keyword\" }}\n}\n}]]]; nested:
QueryParsingException[[test] [term] query does not support [query]];
}]","status":500}

那么,在为某些类型的查询查询 elasticsearch 服务器时,我们是否不能定义分析器,而对于其他类型的查询,我们可以定义分析器?如果不是,我做错了什么吗?

非常感谢任何帮助。

最佳答案

termprefixwildcard 查询期望查询中指定的值已被分析。

关于elasticsearch - 在 elasticSearch 中查询时定义分析器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11657505/

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