Map date as text?


#1

I have json data that has a "product_ref" field (mapped as text) that can take these values as an example:

"product_ref": "N/A"
"product_ref": "90323"
"product_ref": "SN3005"
"product_ref": "2015-05-23"

When pushing the data to the index i get a mapping error:

{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"mapper [root.product_ref] of different type, current_type [date], merged_type [text]"}],"type":"illegal_argument_exception","reason":"mapper [root.product_ref] of different type, current_type [date], merged_type [text]"},"status":400}

How to fix this?


(David Pilato) #2

Set the mapping before indexing the first document.


#3

If already set the mapping as follows:

{
    "mappings" : {
        "root" : {
            "properties" : {
                "product_seller" : {
                    "type" : "text"
                },
                "product_category" : {
                    "type" : "text"
                },
                "product_name" : {
                    "type" : "text"
                },
                "product_ref" : {
                    "type" : "text"
                },
                "product_brand" : {
                    "type" : "text"
                },
                "product_price" : {
                    "type" : "long"
                },
                "product_link" : {
                    "type" : "text"
                }
            }
        }
    }
}

(David Pilato) #4

Really?

Can you tell me what is the output of:

GET YOURINDEXNAME/_mapping

Also an exact document. I think your document has a root object in it which either should not be there or at least does not comply with the mapping.

And all formatted as explained in About the Elasticsearch category.


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.