Hi,
I have index with 25 000 documents which are looks like:
GET locations/location/10/_source
{
"country_code": "US",
"id": "10",
"continent_code": "NA",
"city_name": "New York"
}
I need to get cities from two countries in random order first and all other cities in random order next. Now I can simple show cities from two countries and cities next by query with "should" and "minimum_should_match":
POST locations/_search?size=100
{
"query": {
"bool": {
"should": [
{
"match_all": {}
},
{
"term": {
"country_code": "mz"
}
},
{
"term": {
"country_code": "mg"
}
}
],
"minimum_should_match": 1
}
}
}
But order of first 100 documents is strange: I see some MG cities first, some MZ next, some MG again and PT at the end. Why order is so strange?
Is it possible to see MG and MZ cities in random order and all other cities in random order too? I know about "function_score", but I can't understand how to apply two "random_score" for both parts of results - matched and unmatched.