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

Supporting dots ('.') as separator for dynamic_date_formats #10961

Closed
gmoskovicz opened this issue May 4, 2015 · 7 comments
Closed

Supporting dots ('.') as separator for dynamic_date_formats #10961

gmoskovicz opened this issue May 4, 2015 · 7 comments
Labels
>bug help wanted adoptme :Search/Mapping Index mappings, including merging and defining field types

Comments

@gmoskovicz
Copy link
Contributor

dynamic_date_formats does don't support dots in mapping

Steps to repro

1- Modify default-mapping.json file and add

{
    "_default_" : {
        "dynamic_date_formats" : ["yyyy.MM.dd HH:mm"]
    }
}

2- Create new index and add a new document, without setting the mapping

{
    "my_date": "2012.03.08 12:30"
}

3- Verify that the my_date field is stored as string, and not as date

{
    "tryit_now": {
        "mappings": {
            "dateFormats": {
                "dynamic_date_formats": [
                    "yyyy.MM.dd HH:mm"
                ],
                "properties": {
                    "my_date": {
                        "type": "string"
                    }
                }
            }
        }
    }
}

According to the DocumentParser.java we only allow ":", "-" and "/" for separator for dynamic dates.

@gmoskovicz gmoskovicz added the >bug label May 4, 2015
@gmoskovicz
Copy link
Contributor Author

The workaround for this will be to refactor our mapping and add slashes to the dynamic format:

{
    "_default_" : {
        "dynamic_date_formats" : ["yyyy/MM/dd HH:mm"]
    }
}

Also, to use any of the date formats suggested in our documentation.

@clintongormley
Copy link

@gmoskovicz In what locales are periods used in dates by default?

@gmoskovicz
Copy link
Contributor Author

@clintongormley we have been seeing that some systems are using dot separator as the default for their dates.

A wat to hack this is also to add seconds to the date format, therefore it will contain 2 ":" and will overpass the restriction:

{
    "_default_" : {
        "dynamic_date_formats" : ["yyyy.MM.dd HH:mm:ss"]
    }
}

Nowadays the restriction is that the full pattern should contain at least 2 ":", two "-" or two "/"

@gmoskovicz
Copy link
Contributor Author

But i am concerned also that there are not strict locales using periods in dates by default.

@clintongormley
Copy link

The problem with using periods for date detection is that it could break floating point numbers, written as strings. Also, I don't know of any locales that use periods by default (but that may just be ignorance).

We could reduce the requirement for "more than 1" colon, slash etc for date detection. Or maybe this would cease to be an issue if we finally get around to merging #6227

/cc @spinscale

@gmoskovicz
Copy link
Contributor Author

According to this there are some using dots as separator.

@clintongormley
Copy link

Closing in favour of #1694

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug help wanted adoptme :Search/Mapping Index mappings, including merging and defining field types
Projects
None yet
Development

No branches or pull requests

2 participants