new to this forum, running engineering at a startup which is using OpenSearch in AWS for our search engine, version 2.7 right this minute.
i am trying to get a sort by relevance score, and then distance when there are multiple identical relevance scores. it’s not really working, and i’m not sure what to do next. the online docs don’t say it can do this, but they don’t say it can’t and offer no examples, so i just tried it. the order by relevance score is ok, the distance order is not.
i don’t know if i missed something or this is simply not expected to work. i’m prepared to do the distance sort outside of OpenSearch if i need to. please advise.
this is the sort clause from my Laravel (php) code:
$query
.= ',
"sort": [
{
"_score": {
"order" : "desc"
}
},
{
"_geo_distance": {
"location.location": {
"lon": ' . floatval($searchLocation['lng']) . ',
"lat": ' . floatval($searchLocation['lat']) . '
},
"order": "asc",
"unit": "mi",
"distance_type": "plane",
"mode": "min",
"ignore_unmapped": true
}
}
]';