It appears "min" is not a viable option for the score_mode on nested
queries. Would it be possible to add this? Or another way to "fake" the
I have a nested document structure, where a single "Product" can contain
multiple "Vendors" who sell the product. Each vendor has a "productCost"
property which is the price of the product.
I'm attempting to sort these by price in Ascending order. To accomplish
this with the nested documents, I'm applying a custom_score to each
"Vendor" nested document, where the score == price. I then sort the entire
set by the _score ascending.
This works mostly ok. Search results are sorted by price ascending.
However, since the score_mode on nested cannot do "min", products with
multiple vendors can be mis-sorted ($10 vendor and $100 vendor will cause
the parent doc to sort incorrectly, since both Avg and Max return too high
of a value)
I realize I can denormalize my fields and make the parent doc contain a
"lowestPrice" field which is kept current. If there is no other way to
perform this query I'll use this approach.