Unable to aggregate based on comma sepperated values

Hi,
I wanna apply comma tokenizer to Product field for aggregation according comma separated values.I tried below code:

PUT /cap_log/_mapping/prodtype
{
"properties" : {
"Product" : {
"type" : "text",
"analyzer" : "commapattern",
"fielddata": true
}
}
}

but it is showing error like this:

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Mapper for [Product] conflicts with existing mapping in other types:\n[mapper [Product] has different [analyzer]]"
}
],
"type": "illegal_argument_exception",
"reason": "Mapper for [Product] conflicts with existing mapping in other types:\n[mapper [Product] has different [analyzer]]"
},
"status": 400
}

I updated code like:

PUT /cap_log/_mapping/my_type?update_all_types
{
"properties": {
"Product": {
"type": "text",
"analyzer": "commapattern"
}
}
}

but still showing same error.Please give solution.or any alternate way to do it.

You cannot change the mapping (including the analyzer) of an existing field. What you need to do if you want to change the mapping of existing documents is reindex those documents to another index with the updated mapping.

So, first create a new index, which you create with the new mapping. Then use the reindex API to get all documents from the old index A into the new index B. As those documents get reindexed, they will get the updated mapping applied to them. More info about the reindex API here: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html

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