Hi,
Yes, you can limit your search results to the top 10,000 records. This is actually the default limit in Elasticsearch for a single query. If you need to retrieve more than 10,000 results, you would typically use the Scroll or Search After API, but in your case, it sounds like you want to avoid this due to performance concerns.
Here's an example of how you can limit your search results:
GET /your_index/_search
{
"query": {
"match": {
"title": "doctor"
}
},
"size": 10000
}
This will return the top 10,000 matches for "doctor" in the title field.
As for your questions about filtering and sorting, yes, you can apply filters and sorting to these 10,000 records. The filters and sorting will be applied at query time, so they will only affect the top 10,000 records that match your query.
Here's an example of how you can apply a filter and sort your results:
GET /your_index/_search
{
"query": {
"bool": {
"must": {
"match": {
"title": "doctor"
}
},
"filter": {
"term": {
"some_field": "some_value"
}
}
}
},
"sort": [
{ "another_field": "asc" }
],
"size": 10000
}
This will return the top 10,000 matches for "doctor" in the title field, that also have "some_value" in "some_field", sorted by "another_field" in ascending order.