Created
April 29, 2014 08:47
-
-
Save brwe/11394327 to your computer and use it in GitHub Desktop.
Using a mixture of `fieldname: { fieldname: {` vs `fieldname.fieldname` for mapping and indexing yields strange results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE testindex | |
PUT testindex | |
# STEP 1: Add mappings for afield.number and afield.text | |
PUT /testindex/sometype/_mapping | |
{ | |
"sometype": { | |
"properties": { | |
"afield.number": { | |
"type": "integer" | |
}, | |
"afield.text": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
GET testindex/_mapping | |
# I expect here that the indexing will not work bcause afield.number is of type integer and indeed, we get the NumberFormatException | |
# STEP 2: Index a document that has the previous defined fields but inside and object | |
POST testindex/sometype/1 | |
{ | |
"afield": { | |
"number": "foo", | |
"text": 4 | |
} | |
} | |
# After that, the mapping contains the object mapping mith afield: { number: of type string | |
GET testindex/_mapping | |
# Indexing the document again yields the same error as before NumberFormatException | |
POST testindex/sometype/1 | |
{ | |
"afield": { | |
"number": "foo", | |
"text": 4 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment