'Azure search - Get Max/Min with paging
I have a large azure index with various fields, including integer fields.
Is it possible to do a search, and get the MAX, and MIN value of a given field for the entire result set, whilst only returning the first page?
I want to avoid having to do 2 searches to achieve this.
I am calling the index from C# Code.
Solution 1:[1]
There is no direct functionality that returns the min and max values as part of a single query. However, you can use facets to solve many examples. A typical use case is when you need to implement a filter control in the UI, like a slider where the min/max is indicated.
Here is an example where I have a property called SomeInt. In my result set I have values ranging from 0 to 175. To my query I add facet=SomeInt and my response allows me to determine the min/max:
"@odata.count": 9473,
"@search.facets": {
"SomeInt": [
{
"count": 2949,
"value": 175
},
{
"count": 95,
"value": 70
},
{
"count": 46,
"value": 0
}
]
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dan Gøran Lunde |
