Hi.
I have a question about sorting by nested fields.
This is just an small example of the hierarchy level (The marketplaces and
the prices are mapped as nested documents):
{ id: "doc1",
name : "test",
marketplaces : [ { "name" : "marketPlace1",
"prices" : [ { "amount": "20.00" },
{ "amount": "40.00" }]
},
{ "name" : "marketPlace2",
"prices" : [{ "amount": "21.00" },
{ "amount": "30.00" }]
}]}
{ id: "doc2",
name : "test2",
marketplaces : [ { "name" : "marketPlace1",
"prices" : [{ "amount": "30.00" },
{ "amount": "35.00" }]
},
{ "name" : "marketPlace2",
"prices" : [{ "amount": "1.00" },
{ "amount": "3.00" }]
}]}
Now I want to search for all documents with the marketplace name :
"marketPlace1" and sort the result by the prices.amount of this
marketplace.
So I expect that in the example the first document will be in first place
and the second document will be in second place.
The filter works fine. I won't see the documents without "marketPlace1" in
the result list.
But the sort doesn't restrict the same as the filter. So I tried to set a
nested filter to match the upper hierarchy too.
I tried this sort, but got the value "Infinity" as sort result. :
"sort" : {
"marketplaces.prices.amount" : { "order" : "asc" , "nested_filter" : {
"term" : {
"marketplaces.name" : "marketPlace1"
}}}}
In case I don't use the nested_filter I get the second document as first
result, because the sorting doesn't consider the marketPlace name.
Is there a solution for my problem?
Thank you very much for your help.
Best regards,
Elke
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/589eae79-0041-4947-879a-f9b7829c3145%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.