H
H
hydra_132019-04-12 13:10:36
elasticsearch
hydra_13, 2019-04-12 13:10:36

Why is the date being processed incorrectly when I try to insert a record?

Greetings!
ElasticSearch 6.2.4
I create a new index with the following settings:

PUT /test1
{
    "settings": {
        "index":{
            "number_of_shards" : 9,
            "number_of_replicas" : 0,
            "max_rescore_window" : 2000000000,
            "max_result_window" : 2000000000
        }
    },
    "mappings": {
        "files": {
            "properties": {
                "Дата добавления в БД": {
                    "type": "date"
                }
            },
            "numeric_detection": true,
            "dynamic_templates": [
                {
                    "integers": {
                        "match_mapping_type": "long",
                        "mapping": {
                            "type": "long"
                        }
                    }
                },
                {
                    "strings": {
                        "match_mapping_type": "string",
                        "mapping": {
                            "type": "keyword"
                        }
                    }
                },
                {
                    "dates": {
                        "match_mapping_type": "date",
                        "mapping": {
                            "format": "yyyy-MM-dd HH:mm:ss||yyyy/MM/dd HH:mm:ss||yyyyMMdd_HH:mm:ss",
                            "type": "date"
                        }
                    }
                }
            ]
        }
    }
}

Next, I try to upload a new record using a bulk request:
POST /test1/files/_bulk
{"create":{"_index":"test1","_type":"files","_id":"0"}}
{"Дата добавления в БД":"2019/04/12 11:42:21"}

As a result, I get the following output:
{
    "took": 1,
    "errors": true,
    "items": [
        {
            "create": {
                "_index": "test1",
                "_type": "files",
                "_id": "0",
                "status": 400,
                "error": {
                    "type": "mapper_parsing_exception",
                    "reason": "failed to parse [Дата добавления в БД]",
                    "caused_by": {
                        "type": "illegal_argument_exception",
                        "reason": "Invalid format: \"2019/04/12 11:42:21\" is malformed at \"/04/12 11:42:21\""
                    }
                }
            }
        }
    ]
}

Question: What exactly am I doing wrong? The template is given...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question