弹性搜索结合了聚合

时间:2016-10-27 12:59:17

标签: asp.net elasticsearch aggregation nest

目前查询下面删除单个字段上的重复项 - “名称”,但我们需要所有字段的top_hits结果:“name”,“venueName”,“venueTown”。这可以在一个查询中实现而不发送3个请求并将“field”设置为“venueName”和“venueTown”吗?

{
  "aggs": {
    "query": {
      "terms": {
        "field": "name"
      }
     ,
      "aggs": {
        "top": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  },
    "size": 0,
  "query": {

          "multi_match": {
            "query": "LAURA",
            "operator": "OR",
            "fields": [
              "name",
              "venueName",
              "venueTown"
            ]
          }
  }
}

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您可以使用热门点击编写多个聚合。

Calendar cal = Calendar.getInstance();
PendingIntent pintent = PendingIntent.getService(this, 0, new Intent(this, MyService.class), 0);
cal.set(Calendar.MINUTE, MINUTE);
cal.set(Calendar.HOUR_OF_DAY, HOUR);
cal.add(Calendar.DAY_OF_YEAR,1);
AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 86400000, pintent);
running = true;