Elasticsearch mapping update


(Hilal) #1

Hi,
I indexed my mysql datas with ES but my "year" field mapping was wrong.
How do I update my mapping?

My mapping:

PUT my_index/my_type/_mapping
{
"properties" : {
"Year" : {
"type" : "date", 
"format" : "yyyy-MM-dd"
} 

The format was wrong. Actually it should be this way:

PUT my_index/my_type/_mapping
{
"properties" : {
"Year" : {
"type" : "date", 
"format" : "yyyy"
} 

What can I do?


(David Pilato) #2

You have to reindex.

But if you indexed your data already what is wrong then?
Can you explain why the current format you have does not suit your use case?


(Hilal) #3

For example year = "2015" but It was indexed format : yyyy-MM-dd. It have to be format : yyyy

I get an error when I query:

{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Invalid format: \"2015\" is too short"
         }
      ],
      "type": "search_phase_execution_exception",
      "reason": "all shards failed",
      "phase": "query",
      "grouped": true,
      "failed_shards": [
         {
            "shard": 0,
            "index": "titub",
            "node": "93UU8PfmSR6TZQdClhmhIg",
            "reason": {
               "type": "illegal_argument_exception",
               "reason": "Invalid format: \"2015\" is too short"
            }
         }
      ]
   },
   "status": 400
}

It indexed the total data size is 2.5 GB. Data takes too long to re-indexed. Because I carry the Elasticsearch technology from my MySQL data using PHP


(David Pilato) #4

How did you manage to index older data then if they were not using that format YYYY?


(Hilal) #5

you are right. Then the query may be incorrect.


(system) #6