Query DSL - Wildcard Query

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字段包含以开头kiy结尾的词条。匹配的词条可以使kiykitykimchy

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 between 0 and 1.0 decreases the relevance score. A value greater than 1.0 increases the relevance score.

    boost值是相对于默认值的1.0的。介于01.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参数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值