According to ES documentation: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html
That is possible to sort documents by "nested objects".
Does ES instance provided by episerver find supports this?
Or I doing something wrong below?
Mapping that was build in my index (extracted from it):
{"Commerce_Business_Search_ProductDocument": {"dynamic_templates": [
{"nested_template": {"mapping": {"type": "nested"
},"match": "*$$nested"
}
}
],"properties": {"Prices$$nested": {"type": "nested","properties": {"UnitPrice$$number": {"type": "double","ignore_malformed": false
}
}
}
}
}
}
Query:
{"sort": [{"UnitPrice$$number": {"nested_path": "Prices$$nested","mode": "min","order": "desc","ignore_unmapped": false
}
}],"fields": ["___types", "Prices$$nested"]
}
Hits from index (I have only 2 documents there)
[
{"_index": "yauheni_myindex","_type": "Commerce_Business_Search_ProductDocument","_id": "247","_score": null,"fields": {"Prices$$nested": [
{"___types": ["Commerce.Business.Search.ProductPrice","System.Object"
],"ValidFrom$$date": "2014-03-19T12:11:00Z","Warehouse$$string": "","UnitPrice$$number": 10,"$type": "Commerce.Business.Search.ProductPrice, Commerce.Business","Market$$string": "Sweden","ValidUntil$$date": "2015-03-19T12:11:00Z"
}
],"___types": ["Commerce.Business.Search.ProductDocument","System.Object"
],"sort": [
0
]
}
},
{"_index": "yauheni_myindex","_type": "Commerce_Business_Search_ProductDocument","_id": "248","_score": null,"fields": {"CatalogEntryId$$number": 248,"Prices$$nested": [
{"___types": ["Commerce.Business.Search.ProductPrice","System.Object"
],"ValidFrom$$date": "2014-03-19T12:11:00Z","Warehouse$$string": "","UnitPrice$$number": 20,"$type": "Commerce.Business.Search.ProductPrice, Commerce.Business","Market$$string": "Sweden","ValidUntil$$date": "2015-03-19T12:11:00Z"
}
],"___types": ["Commerce.Business.Search.ProductDocument","System.Object"
],"sort": [
0
]
}
}
]
Hits are not sorted, and "sort" fields equals 0 for both of them.