elasticsearch,Java,elasticsearch" /> elasticsearch,Java,elasticsearch" />

Java elasticsearch嵌套筛选器未按预期工作

Java elasticsearch嵌套筛选器未按预期工作,java,elasticsearch,Java,elasticsearch,我在elasticsearch中有这样的文档: { "_index": "4ccda045-3958-4773-bb34-7af26fa52f4e", "_type": "jira", "_id": "BIGHALF-23", "_score": 1, "_source": { "Issue Key": "BIGHALF-23", "Issuetype Name": "Sub-task", "Project

我在elasticsearch中有这样的文档:

{
    "_index": "4ccda045-3958-4773-bb34-7af26fa52f4e",
    "_type": "jira",
    "_id": "BIGHALF-23",
    "_score": 1,
    "_source": {
        "Issue Key": "BIGHALF-23",
        "Issuetype Name": "Sub-task",
        "Project Name": "Big_Half ",
        "Project ID": "10500",
        "Project Key": "BIGHALF",
        "Workratio": -1,
        "Watch Count": 1,
        "Created": "2015-10-08T13:12:47",
        "Priority": "Medium",
        "Assignee Name": "german.solis",
        "Assignee EmailAddress": "german.solis@bighalf.io",
        "Assignee DisplayName": "German Solis",
        "Is Assignee Active": "true",
        "Assigne TimeZone": "America/Chicago",
        "Updated": "2015-10-19T19:21:22",
        "Issue Status": "Done",
        "sprint": [{
            "Sprint ID": "20",
            "Sprint State": "CLOSED",
            "Sprint Name": "Sprint 11",
            "Sprint StartDate": "2015-10-05T01:43:29",
            "Sprint EndDate": "2015-10-12T01:43:00",
            "Sprint CompleteDate": "2015-10-13T14:31:47"
        }, {
            "Sprint ID": "23",
            "Sprint State": "CLOSED",
            "Sprint Name": "Sprint 1",
            "Sprint StartDate": "2015-10-19T01:47:18",
            "Sprint EndDate": "2015-10-26T01:47:00",
            "Sprint CompleteDate": "2015-10-24T23:55:22"
        }, {
            "Sprint ID": "24",
            "Sprint State": "CLOSED",
            "Sprint Name": "Sprint 2",
            "Sprint StartDate": "2015-10-26T11:21:21",
            "Sprint EndDate": "2015-11-01T11:21:00",
            "Sprint CompleteDate": "2015-11-01T23:06:45"
        }],
        "Creator Name": "fernando.velazquez",
        "Creator EmailAddress": "fernando.velazquez@bighalf.io",
        "Creator DisplayName": "fernando.velazquez",
        "Creator Active": "false",
        "Creator TimeZone": "America/Chicago",
        "Reporter Name": "fernando.velazquez",
        "Reporter EmailAddress": "fernando.velazquez@bighalf.io",
        "Reporter DisplayName": "fernando.velazquez",
        "Reporter Active": "false",
        "Reporter TimeZone": "America/Chicago",
        "Aggregate Progress": 0,
        "Aggregate Progress Total": 0,
        "Progress": 0,
        "Progress Total": 0
    }
}
我正在使用传输客户端应用这样的过滤器

{
  "bool" : {
    "must" : [ {
      "nested" : {
        "query" : {
          "bool" : {
            "must" : {
              "terms" : {
                "sprint.Sprint Name" : [ "Sprint 9" ]
              }
            }
          }
        },
        "path" : "sprint"
      }
    }, {
      "terms" : {
        "Assignee DisplayName" : [ "Mateen Khan" ]
      }
    } ]
  }
}
即使在应用了过滤器之后,我也会得到其他sprint的数据。这意味着我正在获取“Sprint7”以及其他sprint的数据。在同一个查询中,我使用传输客户机,也执行一些复杂的聚合

映射:

{
  "4ccda045-3958-4773-bb34-7af26fa52f4e": {
    "mappings": {
      "jira": {
        "properties": {
          "Aggregate Progress": {
            "type": "long"
          },
          "Aggregate Progress Total": {
            "type": "long"
          },
          "Aggregate Progress percent": {
            "type": "long"
          },
          "Aggregate Time Estimate": {
            "type": "long"
          },
          "Aggregate Time Original Estimate": {
            "type": "long"
          },
          "Aggregate Timespent": {
            "type": "long"
          },
          "Assigne TimeZone": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Assignee DisplayName": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Assignee EmailAddress": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Assignee Name": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Created": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss"
          },
          "Creator Active": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Creator DisplayName": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Creator EmailAddress": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Creator Name": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Creator TimeZone": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Description": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Is Assignee Active": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Issue Key": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Issue Status": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Issuetype Name": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Priority": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Progress": {
            "type": "long"
          },
          "Progress Percent": {
            "type": "long"
          },
          "Progress Total": {
            "type": "long"
          },
          "Project ID": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Project Key": {
            "type": "string"
          },
          "Project Name": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Reporter Active": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Reporter DisplayName": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Reporter EmailAddress": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Reporter Name": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Reporter TimeZone": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Sprint Issue Points": {
            "type": "long"
          },
          "Summary": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Time Estimate": {
            "type": "long"
          },
          "Time Original Estimate": {
            "type": "long"
          },
          "Time Tracking Original Estimate": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Time Tracking Original Estimate Seconds": {
            "type": "long"
          },
          "Time Tracking Remaining Estimate": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Time Tracking Remaining Estimate Seconds": {
            "type": "long"
          },
          "Time Tracking Time Spent": {
            "type": "string",
            "index": "not_analyzed"
          },
          "Time Tracking Time Spent Seconds": {
            "type": "long"
          },
          "Updated": {
            "type": "date",
            "format": "yyyy-MM-dd'T'HH:mm:ss"
          },
          "Watch Count": {
            "type": "long"
          },
          "Workratio": {
            "type": "long"
          },
          "sprint": {
            "type": "nested",
            "properties": {
              "Sprint CompleteDate": {
                "type": "date",
                "format": "yyyy-MM-dd'T'HH:mm:ss"
              },
              "Sprint EndDate": {
                "type": "date",
                "format": "yyyy-MM-dd'T'HH:mm:ss"
              },
              "Sprint ID": {
                "type": "string",
                "index": "not_analyzed"
              },
              "Sprint Name": {
                "type": "string",
                "index": "not_analyzed"
              },
              "Sprint StartDate": {
                "type": "date",
                "format": "yyyy-MM-dd'T'HH:mm:ss"
              },
              "Sprint State": {
                "type": "string",
                "index": "not_analyzed"
              }
            }
          }
        }
      }
    }
  }
}

请尝试将
必须
子句中的
术语
替换为
匹配

{
  "bool" : {
    "must" : [ {
      "nested" : {
        "query" : {
          "bool" : {
            "must" : {
              "match" : {
                "sprint.Sprint Name" : [ "Sprint 9" ]
              }
            }
          }
        },
        "path" : "sprint"
      }
    }, {
      "terms" : {
        "Assignee DisplayName" : [ "Mateen Khan" ]
      }
    } ]
  }
}

你能把地图贴出来吗?嗨。我已经更新了映射。也许你认为你的索引使用的映射不是真实的映射。我测试了你的地图和你的样本数据,它对我很有效。嗨,安德烈,索引是真实的安德烈。但是我们在嵌套JSON上执行聚合,而且我们在一个组中有一个子组。即按“sprint.sprint Name”分组,按“Issuetype Name”进一步分组。除此之外,我们还应用了过滤器。索引和映射是正确的,但输出未被过滤。如果你能分享你的联系方式,让我更清楚地解释这个场景,那就太好了。