ElasticSearch Significant Terms Aggregation: doc_count and bg_count unequal for search term

485 Views Asked by At

I'm unsure here if there is something incorrect with my query, my document structure, or my interpretation of the doc_count and bg_count fields.

When running a significant terms aggregation and sorting results by score, the search term is always, understandably, first on that list. However, I would expect that the doc_count and bg_count would match for the search term, because I understand the doc_count to be the number of documents that match both the key and the filter term, and the background count to be the number of documents that match the filter term. So in the case where the filer term is the key, doc_count and bg_count would be equal.

Instead I see in general that the doc_count is lower than the bg_count and the score is (significantly) less than 1.

As an example:

{
"size" : 0,
"timeout" : 1800000,
"query" : {
  "bool" : {
    "filter" : {
      "has_child" : {
        "query" : {
          "term" : {
            "item_id" : 2606
          }
        },
        "child_type" : "item"
      }
    }
  }
},
"aggregations" : {
  "st_agg" : {
    "children" : {
      "type" : "item"
    },
    "aggregations" : {
      "items" : {
        "significant_terms" : {
          "field" : "item_id",
          "size" : 500,
          "exclude" : [ "51713398" ]
         }
       }
     }
   }
 }
}

For these queries, I am not using a background filter. This is on ElasticSearch 2.3.2 (Don't judge, upgrade to 6.x is underway).

Is this expected?

0

There are 0 best solutions below