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

date parse error on range query in es 2 #14565

Closed
jillesvangurp opened this issue Nov 5, 2015 · 5 comments
Closed

date parse error on range query in es 2 #14565

jillesvangurp opened this issue Nov 5, 2015 · 5 comments
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@jillesvangurp
Copy link
Contributor

I have a weird problem where Java 8 adds a plus sign to iso dates if the year is more than 4 characters

LocalDateTime.of(10000, 01, 01, 0, 0).toString()
produces "+10000-01-01T00:00:00.000Z"
LocalDateTime.of(9999, 01, 01, 0, 0).toString()
produces "9999-01-01T00:00:00.000Z"

Before Elasticsearch 2.0 passing this into a range query on a date field was no problem either way but this started breaking during the migration to es 2:

This filter:

{
    "range":{
        "event_at":{
            "from":"0000-01-01T00:00:00.000Z",
            "to":"+10000-01-01T00:00:00.000Z"
        }
    }
}

Now generates the following error:

{
    "shard":0,
    "index":"inbot_activities_v29",
    "node":"4pFF0w30RO6ahMk9OEvqWQ",
    "reason":{
        "type":"parse_exception",
        "reason":"failed to parse date field [+10000-01-01T00:00:00.000Z] with format [strict_date_optional_time||epoch_millis]",
        "caused_by":{
            "type":"illegal_argument_exception",
            "reason":"Invalid format: \"+10000-01-01T00:00:00.000Z\" is malformed at \"-01-01T00:00:00.000Z\""
        }
    }
}

The workaround is obvious and already implemented on my side (-1 to 9999).

But this error was sufficiently weird that I wanted to report it. Maybe it can be fixed by moving from joda to java 8's new date API as I think has been debated already. Alternatively the date pattern used by default could be adapted to allow the + sign.

@lynneker7
Copy link

I have similar problem but a little different. In ElasticSearch 2.0 latest.

Document:


{
    "date": "2015-11-05T05:33:54.431Z",
    "product_id": "27d898e783a16492cafc25a0f9a415d67970b811"
 }

Query


{
  "query": {
    "bool": {
      "must": [
        {
          "match_all": {}
        }
      ],
      "filter": [
        {
          "terms": {
            "product_id": [
              "27d898e783a16492cafc25a0f9a415d67970b811"
            ]
          }
        },
        {
          "range": {
            "date": {
              "lte": "2015-11-05"
            }
          }
        }
      ]
    }
  }
}

Result:


{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

@jillesvangurp
Copy link
Contributor Author

@lynneker7 that looks like the problem is with your query. Change lte to gte and you should see the document since the timestamp is after the queried timestamp.

@lynneker7
Copy link

@jillesvangurp Sorry you're absolutely right. Thanks

@clintongormley clintongormley added :Search Foundations/Mapping Index mappings, including merging and defining field types and removed :Dates labels Feb 13, 2018
@javanna
Copy link
Member

javanna commented Mar 16, 2018

@spinscale any comments on this? cc @elastic/es-search-aggs

@rjernst
Copy link
Member

rjernst commented Aug 16, 2018

ISO 8601 prescribes to use a 4 digit year, supporting years 0000 to 9999. It has an optional portion that uses +/- for years outside that range. It appears joda does not adhere to this part of the spec. We are currently converting joda time uses to java time (see #27330). I'm going to close this as there is no reason to investigate and try of fix joda when it is going away.

@rjernst rjernst closed this as completed Aug 16, 2018
@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

7 participants