Elasticsearch how to use multi_match with wildcard

后端 未结 5 847
再見小時候
再見小時候 2020-12-13 03:55

I have a User object with properties Name and Surname. I want to search these fields using one query, and I found multi_match in the documentation, but I don\'t

5条回答
  •  天涯浪人
    2020-12-13 04:22

    Such a query worked for me:

    {
      "query": {
        "filtered": {
          "query": {
            "match_all": {}
          },
          "filter": {
            "bool": {
              "should": [
                {"query": {"wildcard": {"user.name": {"value": "*mar*"}}}},
                {"query": {"wildcard": {"user.surname": {"value": "*mar*"}}}}
              ]
            }
          }
        }
      }
    }
    

    Similar to what you are doing, except that in my case there could be different masks for different fields.

提交回复
热议问题