Skip to content
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

MissingValues don't work inside sub aggregations () #14882

Closed
DavidHauger opened this issue Nov 20, 2015 · 1 comment

Comments

Projects
None yet
4 participants
@DavidHauger
Copy link

commented Nov 20, 2015

missing values are great to work with - but they do not work within more complex queries.

Here a simple example to reproduce the bug.
Let's say, we have some index, with optional fields:

PUT /missing-values/test/1_with_my_field
{
  "someField": "optionalField_is_present",
  "optionalField": "present"
}
PUT /missing-values/test/1_without_my_field
{
  "someField": "optionalField_is_missing"
}

Now I want to use the fields in some term aggregation. I want information on all items; even if the optional field is missing, so I can use this code:

GET /missing-values/test/_search
{
  "aggregations" : {
    "test": {
      "terms" : {
        "field" : "optionalField",
        "missing": "n/a"
      },
      "aggregations" : {
        "test": {
          "terms" : {
            "field" : "someField"
          }
        }
      }
    }
  }
}

That works fine as long as the missing stuff is applied on the outer level only.
If I change the order of the fields:

GET /missing-values/test/_search
{
  "aggregations" : {
    "test": {
      "terms" : {
        "field" : "someField"
      },
      "aggregations" : {
        "test": {
          "terms" : {
            "field" : "optionalField",
            "missing": "n/a"
          }
        }
      }
    }
  }
}

I receive an exception due to internally used ordinals:
org.elasticsearch.search.aggregations.support.MissingValues$6 cannot be cast to org.elasticsearch.search.aggregations.support.ValuesSource$Bytes$WithOrdinals$FieldData

@dam0vm3nt

This comment has been minimized.

Copy link

commented Dec 30, 2015

I can confirm this bug in 2.1.1 version of ES using java API

jpountz added a commit to jpountz/elasticsearch that referenced this issue Jan 4, 2016

Make `missing` on terms aggs work with all execution modes.
There are two bugs:
 - the 'global_ordinals_low_cardinality' mode requires a fielddata-based impl so
   that it can extract the segment to global ordinal mapping
 - the 'global_ordinals_hash' mode abusively casts to the values source to a
   fielddata-based impl while it is not needed

Closes elastic#14882

jpountz added a commit that referenced this issue Jan 6, 2016

Make `missing` on terms aggs work with all execution modes.
There are two bugs:
 - the 'global_ordinals_low_cardinality' mode requires a fielddata-based impl so
   that it can extract the segment to global ordinal mapping
 - the 'global_ordinals_hash' mode abusively casts to the values source to a
   fielddata-based impl while it is not needed

Closes #14882

jpountz added a commit that referenced this issue Jan 6, 2016

Make `missing` on terms aggs work with all execution modes.
There are two bugs:
 - the 'global_ordinals_low_cardinality' mode requires a fielddata-based impl so
   that it can extract the segment to global ordinal mapping
 - the 'global_ordinals_hash' mode abusively casts to the values source to a
   fielddata-based impl while it is not needed

Closes #14882

jpountz added a commit that referenced this issue Jan 6, 2016

Make `missing` on terms aggs work with all execution modes.
There are two bugs:
 - the 'global_ordinals_low_cardinality' mode requires a fielddata-based impl so
   that it can extract the segment to global ordinal mapping
 - the 'global_ordinals_hash' mode abusively casts to the values source to a
   fielddata-based impl while it is not needed

Closes #14882
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.