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

Inconsistent behavior when loading docvalues for range fields #53246

Closed
jtibshirani opened this issue Mar 6, 2020 · 5 comments
Closed

Inconsistent behavior when loading docvalues for range fields #53246

jtibshirani opened this issue Mar 6, 2020 · 5 comments
Labels
:Analytics/Aggregations Aggregations >bug :Search/Search Search-related issues that do not fall into other categories Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Meta label for search team

Comments

@jtibshirani
Copy link
Contributor

jtibshirani commented Mar 6, 2020

Say we've indexed a document with an integer_range and date_range using version 7.4 (or above):

PUT range_index
{
  "mappings": {
    "properties": {
      "expected_attendees": {
        "type": "integer_range"
      },
      "time_frame": {
        "type": "date_range", 
        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
      }
    }
  }
}

PUT range_index/_doc/1?refresh
{
  "expected_attendees" : { 
    "gte" : 10,
    "lte" : 20
  },
  "time_frame" : { 
    "gte" : "2015-10-31 12:00:00", 
    "lte" : "2015-11-01"
  }
}

If we specify "docvalues_fields": ["time_frame"] during a search, we get an unsupported operation exception because of a failure in DocValueFormat.format:

Caused by: java.lang.UnsupportedOperationException
	at org.elasticsearch.search.DocValueFormat.format(DocValueFormat.java:70) ~[elasticsearch-7.4.1.jar:7.4.1]
	at org.elasticsearch.search.fetch.subphase.DocValueFieldsFetchSubPhase.hitsExecute(DocValueFieldsFetchSubPhase.java:159) ~[elasticsearch-7.4.1.jar:7.4.1]
	at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:177) ~[elasticsearch-7.4.1.jar:7.4.1]

When specifying "docvalues_fields": ["expected_attendees"], we don't get an error but a binary representation is returned.

This behavior seems quite confusing. To me it would be best if we either (1) always returned a nicely formatted representation of the range, or (2) always threw a descriptive error.

@jtibshirani jtibshirani added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types labels Mar 6, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@jtibshirani
Copy link
Contributor Author

jtibshirani commented Mar 6, 2020

It looks like there was different behavior prior to 7.4: when requesting docvalues_fields for "time_frame" or "expected_attendees", we always get an error of the form "Fielddata is not supported on field [time_frame] of type [date_range]". I wonder if some of our recent work on running aggregations on range fields caused the change in behavior.

@jtibshirani jtibshirani added :Search/Search Search-related issues that do not fall into other categories and removed :Search Foundations/Mapping Index mappings, including merging and defining field types labels Apr 29, 2020
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Apr 29, 2020
@jtibshirani jtibshirani added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/Aggregations Aggregations labels Apr 29, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@romseygeek
Copy link
Contributor

Histogram fields have a clear separation here in that they explicitly throw an error when you ask for their ScriptDocValues. I think we should extend this to range fields as well? Either that or expose an object of some kind that returns the range bounds so that they can be used in scripts.

@jtibshirani
Copy link
Contributor Author

We decided not to invest in fixing this, so I'm closing it out. The recommended way to load these values is through the new fields option instead of docvalue_fields. As part of our testing efforts around field loading (#70929) we could look into throwing clearer errors for field types that aren't supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >bug :Search/Search Search-related issues that do not fall into other categories Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Search Meta label for search team
Projects
None yet
Development

No branches or pull requests

4 participants