-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Elasticsearch version (bin/elasticsearch --version):
Version: 7.10.2, Build: default/tar/747e1cc71def077253878a59143c1f785afa92b9/2021-01-13T00:42:12.435326Z, JVM: 11.0.6
Plugins installed: []
JVM version (java -version):
java version "11.0.6" 2020-01-14 LTS
OS version (uname -a if on a Unix-like system):
18.7.0 Darwin Kernel Version 18.7.0: Fri Oct 30 12:37:06 PDT 2020; root:xnu-4903.278.44.0.2~1/RELEASE_X86_64 x86_64
Description of the problem including expected versus actual behavior:
When creating a mapping with a geo_point field and "index":false, the index property gets ignored. The expected behavior is that that field is not getting index, and "index" property is retained in the mapping. The other problem is adding any new field to the mapping fails.
Steps to reproduce:
- Create an index:
curl -XPUT "localhost:9200/test_index" - Put a mapping:
curl -XPUT "localhost:9200/test_index/_mapping" --header "Content-Type: application/json" -d '
{
"properties": {
"email": {
"type": "keyword",
"index" : false
},
"location" : {
"type" : "geo_point",
"index" : false
}
}
}'
- Check the mapping:
curl -X GET "localhost:9200/test_index/_mapping?pretty"
{
"test_index" : {
"mappings" : {
"properties" : {
"email" : {
"type" : "keyword",
"index" : false
},
"location" : {
"type" : "geo_point"
}
}
}
}
}
As you can see, "index":false is missing for location field.
4. now add a new field to the mapping:
curl -XPUT "localhost:9200/test_index/_mapping?pretty" --header "Content-Type: application/json" -d '
{
"properties": {
"email": {
"type": "keyword",
"index" : false
},
"location" : {
"type" : "geo_point",
"index" : false
},
"age": {
"type": "integer",
"index" : false
}
}
}'
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values, mapper [location] has different [index_options] values]"
}
],
"type" : "illegal_argument_exception",
"reason" : "Mapper for [location] conflicts with existing mapping:\n[mapper [location] has different [index] values, mapper [location] has different [index_options] values]"
},
"status" : 400
}
As you can see, even though the only difference between two mapping requests is the addition of a new field, the request fails because the created mapping in (2) is different from what was actually in the mapping request.
The same steps work in ES 7.5.2, the output of step 3 there is
curl -X GET "localhost:9200/test_index/_mapping?pretty"
{
"test_index" : {
"mappings" : {
"properties" : {
"email" : {
"type" : "keyword",
"index" : false
},
"location" : {
"type" : "geo_point",
"index" : false
}
}
}
}
}
and step 4 also works:
curl -XPUT "localhost:9200/test_index/_mapping?pretty" --header "Content-Type: application/json" -d '
{
"properties": {
"email": {
"type": "keyword",
"index" : false
},
"location" : {
"type" : "geo_point",
"index" : false
},
"age": {
"type": "integer",
"index" : false
}
}
}'
{
"acknowledged" : true
}
curl -X GET "localhost:9200/test_index/_mapping?pretty"
{
"test_index" : {
"mappings" : {
"properties" : {
"age" : {
"type" : "integer",
"index" : false
},
"email" : {
"type" : "keyword",
"index" : false
},
"location" : {
"type" : "geo_point",
"index" : false
}
}
}
}
}