弹性搜索:在聚合中突出显示

时间:2016-08-22 14:53:54

标签: elasticsearch

我尝试运行以下ES查询以突出显示聚合中的结果。只有我发现的一种方法是使用Top来获取提示并突出显示值。查询如下所示:

{
"size" : 10,
  "query" : {
    "bool" : {
      "must" : {
        "bool" : {
          "should" : [ {
            "constant_score" : {
              "filter" : {
                "wildcard" : {
                  "nameLegal.keyword" : "s*"
                }
              },
              "boost" : 5.0
            }
          }, {
            "match" : {
              "nameLegal.cleansed" : {
                "query" : "s",
                "type" : "boolean",
                "boost" : 5.0,
                "fuzziness" : "AUTO"
              }
            }
          } ]
        }
      },
      "disable_coord" : true
    }
  },
  "min_score" : 1.0,
  "_source" : {
    "includes" : [ "nameLegal" ],
    "excludes" : [ ]
  },
  "aggregations" : {
    "dedup" : {
      "terms" : {
         "field" : "nameLegal.keyword"
       },
       "aggregations" : {
         "top" : {
           "top_hits" : {
             "size" : 1,
             "highlight" : {
               "pre_tags" : [ "<hl>" ],
               "post_tags" : [ "</hl>" ],
               "fields" : {
                 "nameLegal.keyword" : {},
                 "nameLegal.cleansed" : {}
               }
             }
           }
         }
       }
    }
   }
 }

问题是我没有获得“nameLegal.cleansed”的突出显示值,但我只是为“nameLegal.keyword”获得突出显示的值。

你能否提出可能存在问题的建议?

0 个答案:

没有答案