You obviously can't use a nested
query across both old and new indices, because the old field isn't mapped as nested
. If you do try to do that, you'll get an exception reported in the shards
section of the old index, but you'll still get results from the new index, eg:
PUT t1
{
"mappings": {
"t": {
"properties": {
"foo": {
"type": "object"
}
}
}
}
}
PUT t2
{
"mappings": {
"t": {
"properties": {
"foo": {
"type": "nested"
}
}
}
}
}
PUT t1/t/1
{
"foo": {
"bar": "baz"
}
}
PUT t2/t/2
{
"foo": {
"bar": "baz"
}
}
GET t*/_search
{
"query": {
"nested": {
"path": "foo",
"query": {
"match": {
"foo.bar": "baz"
}
}
}
}
}
returns:
{
"took": 12,
"timed_out": false,
"_shards": {
"total": 10,
"successful": 5,
"failed": 5,
"failures": [
{
"shard": 0,
"index": "t1",
"node": "OEftVv31Tfuvi9_v10ohVA",
"reason": {
"type": "query_shard_exception",
"reason": """
failed to create query: {
"nested" : {
"query" : {
"match" : {
"foo.bar" : {
"query" : "baz",
"operator" : "OR",
"prefix_length" : 0,
"max_expansions" : 50,
"fuzzy_transpositions" : true,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}
},
"path" : "foo",
"ignore_unmapped" : false,
"score_mode" : "avg",
"boost" : 1.0
}
}
""",
"index_uuid": "HWb99ARUSGOQi0ZisNV9vw",
"index": "t1",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] nested object under path [foo] is not of nested type"
}
}
}
]
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"hits": [
{
"_index": "t2",
"_type": "t",
"_id": "2",
"_score": 0.2876821,
"_source": {
"foo": {
"bar": "baz"
}
}
}
]
}
}