Inner hits returned in reversed order in ES7 as compared to ES6

Hello, while migrating to ES7 we noticed that the inner hits are returned in a different order as compared to ES6. For e.g., consider a document that contains a nested field with 4 entries say 1,2,3 and 4. The nested fields returned by ES6 are in order 4,3 and 2 while ES7 returns 1,2 and 3. Is this change intentional ? Is there any way to get the previous behavior ?

To replicate:

Create index with this mapping (remove the type for ES7)

{
"mappings": {
"_doc" : {
"dynamic": "strict",
"properties": {
"name": {
"type": "text"
},
"nested_field": {
"type": "nested",
"properties": {
"id": {
"type": "integer"
}
}
}
}
}
}
}

Insert a document:

{
"name": "test",
"nested_field": [
{
"id": 1
},
{
"id": 2
},
{
"id": 3
},
{
"id": 4
}
]
}

Query the index:

{
"query": {
"bool": {
"filter": [
{
"nested": {
"path": "nested_field",
"query": {
"match_all": {}
},
"inner_hits": {}
}
}
]
}
}
}

Inner hits returned in ES6:

"inner_hits": {
"nested_field": {
"hits": {
"total": 4,
"max_score": 1.0,
"hits": [
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 3
},
"_score": 1.0,
"_source": {
"id": 4
}
},
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 2
},
"_score": 1.0,
"_source": {
"id": 3
}
},
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 1
},
"_score": 1.0,
"_source": {
"id": 2
}
}
]
}
}
}

Inner hits returned in ES7:

"inner_hits": {
"nested_field": {
"hits": {
"total": {
"value": 4,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 0
},
"_score": 1.0,
"_source": {
"id": 1
}
},
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 1
},
"_score": 1.0,
"_source": {
"id": 2
}
},
{
"_index": "test_index",
"_type": "_doc",
"_id": "1",
"_nested": {
"field": "nested_field",
"offset": 2
},
"_score": 1.0,
"_source": {
"id": 3
}
}
]
}
}
}

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