如何在ElasticSearch中使用通配符来搜索?

3

Elasticsearch提供了'Terms'和'Wildcard'。'Terms'用于搜索多个OR条件:

        {
          "terms": {
           "IP": [
              "192.168.100.11",
              "192.168.100.13"
            ]
          }

“通配符”是由*(星号)表示的:
        {
          "wildcard": {
            "IP": "192.168.*.11"
          }

我想合并“通配符”和“词项”功能。我该怎么做?例如:
        {
          "wildcard": {
           "IP": [
              "192.168.*.11",
              "192.168.*.13"
            ]
          }
1个回答

8

您可以使用boolshould部分,我认为没有像wildcard那样的"terms"查询,并且should的行为类似于OR

{
  "query": {
    "bool": {
      "should": [
        {"wildcard": {"IP": "192.168.*.11"}},
        {"wildcard": {"IP": "192.168.*.13"}}
      ]
    }
  }
}

谢谢Andrei Stefan! - Inyoung Lee

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接