Hi,
We have a set of documents that need sorting when querying. sorting at the nested level seems to be ok, but we need to sort by a field on a nested object within another nested object and can't for the life of us work this out
The basic document structure looks like:
{
"properties" : {
"doc" : {
"properties" : {
"productCode" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword" } } },
"productSku" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword" } } },
//
// Truncated for clarity
//
"products" : {
"type" : "nested",
"include_in_parent" : true,
"properties" : {
"departureDate" : {"type" : "date", "fields" : { "keyword" : { "type" : "keyword" }, "raw2" : { "type" : "string", "index" : "not_analyzed"} } },
"travelBy" : { "type" : "text", "fields" : { "keyword" : { "type" : "keyword" } } },
//
// Truncated for clarity
//
"calculatedPrices" : {
"type" : "nested",
"properties" : {
"accommodationCode" : {"type" : "string", "fields" : {"keyword" : {"type" : "keyword" } } },
"was" : {"type" : "double"},
"now" : {"type" : "double"},
"isSupplemented" : {"type" : "boolean"},
"isDefaultPrice" : {"type" : "boolean"},
//
// Truncated for clarity
//
}
}
}
}
}
}
}
}
we need to sort by the doc.products.calculatedPrices.now field in either asc or desc order - but only on those that are within the inner hits not values that don't match the rest of the select query.
we can sort fairly easily on doc.products.departureDate for example - but not the next level down.
Is this even possible?
any pointers would be appreciated.
Phil