Help setting up bulk index

Hi,

I have a sample index called "restaurants" with an explicit mapping as follows

{
"mappings": {
"categories": {
"_source": {
"enabled": true
},
"numeric_detection": true,
"date_detection": true,
"properties": {
"restaurant": {
"properties": {
"name": {
"type": "text"
},
"current_address": {
"type": "text"
},
"zip": {
"type": "text"
},
"location": {
"type": "geo_point"
}
}
}
}
}

This is the command to create the index:
curl -XPUT 'localhost:9200/restaurants?pretty' -d @restaurant-mappings.json -H 'Content-type: application/json'

I try the bulk method of adding documents. The first command works ok
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/restaurants/mediterranean/_bulk?pretty&refresh' --data-binary @"mediterranean_restaurant_data.json"

However the second command throws an error:
curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/restaurants/chinese/_bulk?pretty&refresh' --data-binary @"chinese_restaurant_data.json"

{
"took" : 42,
"errors" : true,
"items" : [
{
"index" : {
"_index" : "restaurants",
"_type" : "chinese",
"_id" : "VOhnGnMBGURHDTdYpAzX",
"status" : 400,
"error" : {
"type" : "illegal_argument_exception",
"reason" : "Rejecting mapping update to [restaurants] as the final mapping would have more than 1 type: [mediterranean, chinese]"
}
}
}
]
}

What am I doing wrong here ?

Thanks,
AS

Which version es are you using ?

In Elasticsearch 6.x, it is no longer possible to create indices with more than one type, which is why you are seeing the error. This blog post describes this change and the reasons behind it.

Thanks for the reply. So in this case, would i create a type index for "mediterranean" restaurants and another one for "chinese" restaurants and just reference them via a "type" field in the properties, correct ?

Yes, add that as a field in the document so you can filter and group by it later.

Thanks. Its clear now.

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