简体   繁体   中英

ElasticSearch terms_stats query - exclude terms from result

I currently have a terms facet that excludes certain terms from its results, using the exclude option. I tried the same with a term_stats facet but the same results are not dropped.

I have looked at the Elasticsearch documentation ( http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet/ ) and see that the term_stats facet doesn't appear to have an exclude option. Since I don't always trust my full interpretation of the elasticsearch docs I was looking to see if anybody had found a workaround (beyond processing out the results client-side).

This facet doesn't work as expected:

"keywords_bad":{
  "terms_stats":{
    "size":100,
    "value_field":"retweet_count",
    "exclude":["http","consected"],
    "order":"total",
    "key_field":"text"
  }
}

whereas this facet works as expected:

"keywords_good":{    
  "terms":{
    "size":100,
    "exclude":["http","consected"],
    "order":"count",
    "field":"text"
  }
}

Any reasonable suggestions would be appreciated, as this seems a little inconsistent.

UPDATE

Based on the accepted answer by imotov, I created an issue on GitHub at https://github.com/elasticsearch/elasticsearch/issues/2916

terms_stats facet doesn't support exclude at the moment. I would suggest creating an issue on github asking for it to be added.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM