elasticsearch 嵌套查询中的Elasticsearch筛选失败,elasticsearch,postman,elasticsearch,Postman" /> elasticsearch 嵌套查询中的Elasticsearch筛选失败,elasticsearch,postman,elasticsearch,Postman" />

elasticsearch 嵌套查询中的Elasticsearch筛选失败

elasticsearch 嵌套查询中的Elasticsearch筛选失败,elasticsearch,postman,elasticsearch,Postman,我在elasticsearch映射中有一个自定义定义,我使用嵌套对象进行搜索。我想添加一个过滤器,只搜索特定ID。当我尝试使用过滤器时,它不起作用。 这是我的搜索查询: { "_source":"false", "query":{ "nested":{ "path":"custom", "query":{ "multi_match":{

我在elasticsearch映射中有一个自定义定义,我使用嵌套对象进行搜索。我想添加一个过滤器,只搜索特定ID。当我尝试使用过滤器时,它不起作用。 这是我的搜索查询:

{  
      "_source":"false",
      "query":{  
        "nested":{  
             "path":"custom",
             "query":{  
                "multi_match":{  
                        "fields":["custom.text"],
                        "query" : "foo bar whatever",
                        "fuzziness":"AUTO"

                }
             },
              "filter": {
                "term" : {"Id":"100", "200"}    
             },

             "inner_hits":{
                "highlight":{
                    "fields":{
                        "custom.start_time":{}
                    }
                }
             }
          }
       }
    }
映射:

{
    "mappings":{
            "properties":{
                "Id":{
                    "type":"integer"
                },
                "custom":{
                    "type":"nested",
                    "properties":{
                        "text":{
                            "type":"text"
                        },
                        "start_time":{
                            "type":"text"
                        },
                        "end_time":{
                            "type":"text"
                        }

                    }

                }
        }
    }
}

好的,您已经混合了嵌套和非嵌套。以下是一个适用于您的查询:

{
  "_source": "false",
  "query": {
    "bool": {
      "filter": [
        {
          "terms": {
            "Id": [
              "100",
              "200"
            ]
          }
        },
        {
          "nested": {
            "path": "custom",
            "query": {
              "multi_match": {
                "fields": [
                  "custom.text"
                ],
                "query": "foo bar whatever",
                "fuzziness": "AUTO"
              }
            },
            "inner_hits": {
              "highlight": {
                "fields": {
                  "custom.start_time": {}
                }
              }
            }
          }
        }
      ]
    }
  }
}

你能展示你的地图吗?@Val我已经更新了。