I want to query some ids from a index by DSL. The index mapping can be as:
PUT /my_index
{
"mappings": {
"properties": {
"item_id": {
"type": "keyword"
},
"city": {
"type": "keyword"
},
"title": {
"type": "text"
}
}
}
}
My concern is how to limit the return size for each unique city when querying the title, say top 10 BM25 score item for each city. In addition, when the city value is null or “nationwide”, the limit of return size should be no longer valid in these two case.
Logically it is equivalant to SQL “over partition” + “rank()”, though. I referred to the doc and find “agg” is fine. But haven’t got a clue of whether using top_hits, top_metrics or some other syntax.