Elasticsearch array property must contain given array items

后端 未结 3 1284
谎友^
谎友^ 2021-01-03 11:21

I have documents that look like:

{
    \"tags\" => [
        \"tag1\",
        \"tag2\",
    ],
    \"name\" => \"Example 1\"
}

{
    \"tags\" => [         


        
3条回答
  •  遥遥无期
    2021-01-03 11:36

    You can set minimum_should_match to match your array:

    {
        "query": {
            "filtered": {
               "query": {
                   "match_all": {}
               },
               "filter": {
                   "bool": {
                       "must": [
                          {
                              "terms": {
                                 "tags": ["tag1","tag3"],
                                 "minimum_should_match": 2
                              }
                          }
                       ]
                   }
               }
           }
        }
    }
    

提交回复
热议问题