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 type Locale does not seem to work #25515

Closed
dadoonet opened this issue Jul 3, 2017 · 6 comments
Closed

Date type Locale does not seem to work #25515

dadoonet opened this issue Jul 3, 2017 · 6 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

@dadoonet
Copy link
Member

dadoonet commented Jul 3, 2017

Same as reported for Ingest: See #25513
I came to this while working on a discuss problem

Here is a recreation script (tested on 5.4.2):

DELETE test
PUT test
{
  "mappings": {
    "doc": {
      "properties": {
        "date": {
          "type": "date",
          "format": "MMM y",
          "locale": "FRENCH"
        }
      }
    }
  }
}
PUT test/doc/1
{
  "date": "may 2017"
}
PUT test/doc/2
{
  "date": "mai 2017"
}

Gives:

# DELETE test
{
  "acknowledged": true
}

# PUT test
{
  "acknowledged": true,
  "shards_acknowledged": true
}

# PUT test/doc/1
{
  "_index": "test",
  "_type": "doc",
  "_id": "1",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 1,
    "failed": 0
  },
  "created": true
}

# PUT test/doc/2
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse [date]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse [date]",
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "Invalid format: \"mai 2017\""
    }
  },
  "status": 400
}
@cbuescher
Copy link
Member

@dadoonet when I look at the javadoc for Locale which we use to parse the locale parameter, the correct locale code for france seems to be "fr". When you uses this it rejects "may" and accepts "mai". I tried it your example with random garbage "locale" settings ant they seem to default to Root rather than throw an error. Maybe we should detect that and throw an exception, but unless I'm missing something the locale code here is simply wrong.

@dadoonet
Copy link
Member Author

dadoonet commented Jul 3, 2017

Great! fr is exactly what is needed here.
I believe it needs more documentation or as you said a way to reject unknown locale. I'm changing the label to discuss instead.

Thanks a lot @cbuescher

@dadoonet dadoonet added discuss and removed >bug labels Jul 3, 2017
@dadoonet
Copy link
Member Author

dadoonet commented Jul 3, 2017

BTW this is weird to me that ingest does not seem to use the same way of defining locales...

This is failing for instance. I reported it in #25513.

POST _ingest/pipeline/_simulate
{
  "pipeline": {
    "processors": [
      {
        "date": {
          "field": "date",
          "locale": "fr",
          "formats": [
            "MMM y"
          ]
        }
      }
    ]
  },
  "docs": [
    {
      "_source": {
        "date": "May 2017"
      }
    },
    {
      "_source": {
        "date": "Mai 2017"
      }
    }
  ]
}

@cbuescher
Copy link
Member

We discussed this in FixIt Friday and agreed that it would be preferable reject unknown locales here (and use the same resolution process in the Ingest Date Processor) but this will need some investigation of how to do it. Relabeling this accordingly.

@alexshadow007
Copy link
Contributor

@dadoonet This was fixed by #26361

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

jpountz commented Mar 13, 2018

Fixed via #26361. Thanks @alexshadow007 !

@jpountz jpountz closed this as completed Mar 13, 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

6 participants