Skip to content

With min_doc_count: 0, terms agg now creating null bucket (new in 1.5.1?) #10640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tylerprete opened this issue Apr 17, 2015 · 3 comments
Closed

Comments

@tylerprete
Copy link

Running this query on my data:

GET beta/place/_search?search_type=count
{
 "query": {
   "match_all": {}
 },
 "aggs": {
   "ratings": {
     "terms": {
       "field": "price",
       "size": 100,
       "min_doc_count": 0
     }
   }
 }
} 

I'm getting this back:

   "aggregations": {
      "ratings": {
         "doc_count_error_upper_bound": 0,
         "sum_other_doc_count": 0,
         "buckets": [
            {
               "key": "2",
               "doc_count": 612985
            },
            {
               "key": "1",
               "doc_count": 542859
            },
            {
               "key": "3",
               "doc_count": 125294
            },
            {
               "key": "4",
               "doc_count": 57340
            },
            {
               "key": "null",
               "doc_count": 0
            }
         ]
      }
   }

At the very least, I can say I'm not getting null buckets in version 1.3.9. I don't have any 1.4 servers up right now to check.

Also, it only happens for min_doc_count=0. If I remove that, it goes away.

Is this desired behavior?

I found this existing issue: #6273
but that seems to asking for a null bucket, and it's still open.

@jpountz
Copy link
Contributor

jpountz commented Apr 18, 2015

This can happen if you have a deleted document which is only marked as deleted for now and has "null" as a value for "price". See first note under http://www.elastic.co/guide/en/elasticsearch//reference/1.5/search-aggregations-bucket-terms-aggregation.html#_minimum_document_count

@jpountz jpountz closed this as completed Apr 18, 2015
@tylerprete
Copy link
Author

Just FYI, this index doesn't have any deleted documents. We never issue deletes with our workflow. And I only started seeing it in ES 1.5+. But it's fine, I can workaround it.

@jpountz
Copy link
Contributor

jpountz commented Apr 20, 2015

@tylerprete Then maybe you have other types on the same index and null is a possible value on those types for the price field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants