Last active
August 29, 2015 14:03
-
-
Save tstibbs/dc36483f96f8d1471385 to your computer and use it in GitHub Desktop.
Elasticsearch field 'copy_to' disagrees with itself
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
curl -XPUT 'http://localhost:9200/index1' -d ' | |
{ | |
"mappings": { | |
"parent": { | |
"properties": { | |
"children": { | |
"type": "nested", | |
"properties": { | |
"colour": { | |
"type": "string" | |
}, | |
"make": { | |
"type": "string", | |
"copy_to": "copied" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
' | |
curl -XPUT 'http://localhost:9200/index1/parent/1' -d ' | |
{ | |
"children": [ | |
{ | |
"colour": "blue", | |
"make": "ford" | |
}, | |
{ | |
"colour": "red", | |
"make": "rover" | |
} | |
] | |
} | |
' | |
curl -XGET 'http://localhost:9200/index1/_mapping?pretty=true' | |
# returns this (note the location of the 'copied' field): | |
{ | |
"index1" : { | |
"mappings" : { | |
"parent" : { | |
"properties" : { | |
"children" : { | |
"type" : "nested", | |
"properties" : { | |
"colour" : { | |
"type" : "string" | |
}, | |
"make" : { | |
"type" : "string", | |
"copy_to" : [ "copied" ] | |
} | |
} | |
}, | |
"copied" : { | |
"type" : "string" | |
} | |
} | |
} | |
} | |
} | |
} | |
# From looking at the mapping, we would expect this query to return the document (it doesn't): | |
curl -XPOST 'http://localhost:9200/index1/_search' -d ' | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"match" : { | |
"copied" : "rover" | |
} | |
}, | |
{ | |
"nested": { | |
"path": "children", | |
"score_mode": "avg", | |
"query": { | |
"match": { | |
"colour": "red" | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
} | |
' | |
# From looking at the mapping, we would not expect this query to return the document (it does): | |
curl -XPOST 'http://localhost:9200/index1/_search' -d ' | |
{ | |
"query": { | |
"nested": { | |
"path": "children", | |
"score_mode": "avg", | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"match": { | |
"copied": "rover" | |
} | |
}, | |
{ | |
"match": { | |
"colour": "red" | |
} | |
} | |
] | |
} | |
} | |
} | |
} | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment