[英]Elasticsearch query_string search using wildcard
Elasticsearch when queried with the following returns no results. 当查询以下内容时,Elasticsearch不返回任何结果。
{
"query":{
"filtered":{
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"a*",
"analyze_wildcard":true
}
}
]
}
}
}
}
}
When I use "al*" instead of "a*", I am getting proper results. 当我使用“ al *”代替“ a *”时,我得到了正确的结果。 This is happening for "a*" only.
这仅针对“ a *”发生。 When I use any others like "b*" or "c*", etc. the results are proper
当我使用“ b *”或“ c *”等其他任何字符时,结果都是正确的
I am using elasticsearch version 0.90.12 我正在使用Elasticsearch 0.90.12版
This is because a
is a stop word and gets eliminated by the standard analyzer that analyzes your query. 这是因为
a
是一个停用词,并被分析您的查询的标准分析器所消除。 You can probably get around this by specifying a different analyzer, such as keyword
instead of using the standard
one. 您可以通过指定其他分析器来解决此问题,例如使用
keyword
而不是使用standard
分析器。 Another option is to leave analyze_wildcard
set to false
. 另一种选择是将
analyze_wildcard
设置为false
。
{
"query":{
"filtered":{
"query":{
"bool":{
"should":[
{
"query_string":{
"query":"a*",
"analyze_wildcard":true,
"analyzer": "keyword"
}
}
]
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.