[英]Elasticsearch query_string wildcard syntax
Apparently I can query ES with the following wildcard query_string
: 显然,我可以使用以下通配符
query_string
查询ES:
curl 'http://localhost:9200/my-index/_search?pretty' -d '{
"query": {
"query_string": {
"query": "*:sw?ft"
}
}
}'
Does this query against _all
field ? 此查询是否针对
_all
字段? which makes it equivalent to: 这等效于:
curl 'http://localhost:9200/my-index/_search?pretty' -d '{
"query": {
"query_string": {
"default_field" : "_all"
"query": "sw?ft"
}
}
}'
what if _all
is disabled in indexing? 如果在索引中禁用
_all
怎么办? I couldn't find the documentation for it. 我找不到它的文档。
Thanks in advance. 提前致谢。
A query_string
with the searching command set to *:sw?ft
will be transformed to something like the following (assuming your my-index
index has a single my_field
field, for example): 一个
query_string
与搜索命令设置为*:sw?ft
将被转化为类似以下的(假设你的my-index
指数有一个my_field
场为例):
(_field_names:sw?ft | _all:sw?ft | _index:sw?ft | _parent:sw?ft | _uid:sw?ft | _type:sw?ft | _routing:sw?ft | _version:sw?ft | _timestamp:sw?ft | _source:sw?ft | _size:sw?ft | my_field:sw?ft | _id:sw?ft | _ttl:sw?ft | _boost:sw?ft)
So, the wildcard before :
will be expanded to all the fields in the index, not only your own defined fields. 因此,
:
之前的通配符将扩展到索引中的所有字段,而不仅仅是您自己定义的字段。 Be very careful with wildcards in query_string
, they can affect in a bad way the performance of the cluster. 请特别注意
query_string
通配符,它们可能以不利的方式影响集群的性能。
So, to answer your question, *
will be expanded to all the fields of the index, including _all
. 因此,为回答您的问题,
*
将扩展到索引的所有字段,包括_all
。 If you would have used just sw?ft
as searching string then this, by default, would have been used _all
. 如果只使用
sw?ft
作为搜索字符串,则默认情况下将使用_all
。
First of all, that's documentation for query_string query: 首先,这是query_string查询的文档:
And it has answers to both of your questions: 它可以回答您的两个问题:
When not explicitly specifying the field to search on in the query string syntax, the
index.query.default_field
will be used to derive which field to search on.如果未在查询字符串语法中明确指定要搜索的字段,则将使用
index.query.default_field
导出要搜索的字段。 It defaults to_all
field.默认为
_all
字段。So, if
_all
field is disabled, it might make sense to change it to set a different default field.因此,如果禁用
_all
字段,则可以对其进行更改以设置不同的默认字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.