如何汇总弹性建议结果?

时间:2019-03-26 12:57:14

标签: elasticsearch elasticsearch-aggregation

我正在使用具有以下映射的弹性索引:

{
  "mapping": {
    "concept": {
      "properties": {
        "filter-key": {
          "type": "completion",
          "analyzer": "custom_index_analyzer",
          "search_analyzer": "custom_query_analyzer",
          "preserve_separators": false,
          "preserve_position_increments": true,
          "max_input_length": 50
        },
        "custom_id": {
          "type": "keyword"
        }
      }
    }
  }
}

索引包含例如以下条目:

  {
    "_source" : {
      "filter-key" : {
        "weight" : 22,
        "input" : "ABC"
      },
      "custom_id" : "190006021550"
    }
  },
  {
    "_source" : {
      "filter-key" : {
        "weight" : 31,
        "input" : "ABC"
      },
      "custom_id" : "190006171313"
    }
  },
  {
    "_source" : {
      "filter-key" : {
        "weight" : 37,
        "input" : "ABBB"
      },
      "custom_id" : "190006171313"
    }
  }

现在,我想结合使用弹性建议和聚合,以获取针对查询“ AB”的以下建议:

{"text": "ABC", "custom_ids": ["190006021550","190006171313"]}
{"text": "ABBB", "custom_ids": ["190006171313"]}

因此,实际上我想按以下字段之一(filter-key.input)对建议进行分组。有弹性吗?我是否需要任何特殊的映射定义?

0 个答案:

没有答案