Elasticsearch一个字段匹配不同的值

时间:2019-05-23 11:58:49

标签: elasticsearch

我想执行一个查询,其中一个字段匹配不同的值,在SQL中,它像:

select * from location where address like '%California%' and address like '%145%';

我尝试使用must条件数组,它包含几个词组匹配条件,但是不起作用!

{
  "from" : 0,
  "size" : 10,
  "query" : {
    "bool" : {
      "must" : {
        "bool" : {
          "must" : [ {
            "match" : {
              "address" : {
                "query" : "California",
                "type" : "phrase"
              }
            }
          }, {
            "match" : {
              "address" : {
                "query" : "145",
                "type" : "phrase"
              }
            }
          } ]
        }
      }
    }
  },
  "sort" : [ {
    "pageRankScore" : {
      "order" : "desc",
      "unmapped_type" : "double"
    }
  } ]
}

那是我的代码,它只会匹配“ 145”,而不会匹配“加利福尼亚”。

我的问题是:对于多个值,如何在一个字段中进行模糊匹配?

帮帮我,非常感谢!

0 个答案:

没有答案