Wildcard Query
通配符查询
Returns documents that contain terms matching a wildcard pattern.
返回与通配符模式匹配的词条的文档。
A wildcard operator is a placeholder that matches one or more characters. For example, the *
wildcard operator matches zero or more characters. You can combine wildcard operators with other characters to create a wildcard pattern.
通配符运算符是匹配一个或多个字符的占位符。例如,*
通配符运算符匹配零个或多个字符。您可以将通配符运算符与其他字符结合使用以创建通配符模式。
Example request
The following search returns documents where the user
field contains a term that begins with ki
and ends with y
. These matching terms can include kiy
, kity
, or kimchy
.
下面的搜索返回user
字段包含以开头ki
和y
结尾的词条。匹配的词条可以使kiy
, kity
或kimchy
。
GET /_search
{
"query": {
"wildcard": {
"user": {
"value": "ki*y",
"boost": 1.0,
"rewrite": "constant_score"
}
}
}
}
Copy as cURLView in Console
Top-level parameters for wildcard
-
field
(Required, object) Field you wish to search.
(必填,对象)您要搜索的字段。
Parameters for field
-
value
(Required, string) Wildcard pattern for terms you wish to find in the provided
field
.(必需,字符串)用于您希望在
field
中匹配的通配符模式。This parameter supports two wildcard operators:
此参数支持两个通配符运算符:
-
?
, which matches any single character -
*
, which can match zero or more characters, including an empty one -
?
,它与任何单个字符匹配 -
*
,可以匹配零个或多个字符,包括一个空字符
Avoid beginning patterns with
*
or?
. This can increase the iterations needed to find matching terms and slow search performance.避免使用
*
或?
开头的模式。这会增加查找匹配项所需的迭代次数,并降低搜索性能。 -
-
boost
(Optional, float) Floating point number used to decrease or increase the relevance scores of a query. Defaults to
1.0
.(可选,float)浮点数,用于降低或增加查询的 相关性分数。默认为
1.0
。You can use the
boost
parameter to adjust relevance scores for searches containing two or more queries.您可以使用该
boost
参数来调整包含两个或多个查询的搜索的相关性得分。Boost values are relative to the default value of
1.0
. A boost value between0
and1.0
decreases the relevance score. A value greater than1.0
increases the relevance score.boost值是相对于默认值的
1.0
的。介于0
和1.0
之间的boost值会降低相关性得分。大于1.0
的boost值会增加相关性得分。 -
rewrite
(Optional, string) Method used to rewrite the query. For valid values and more information, see the
rewrite
parameter.(可选,字符串)用于重写查询的方法。其有效值和更多信息,请参阅
rewrite
参数。