首页 > 解决方案 > Elasticsearch 一个字段匹配不同的值

问题描述

我想做一个查询,一个字段匹配不同的值,在 SQL 中它喜欢:

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

我尝试使用必须条件数组,它包含几个短语匹配条件,但它不起作用!

{
  "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',从不匹配'California'。

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

帮帮我,非常感谢!

标签: elasticsearch

解决方案


推荐阅读