Azure Search: price range - calculating the minimum and maximum values

I am currently trying to find the Azure Search SDK. With a strong background working with lucene and BoboBrowse , Azure Search is quite fantastic and has many features from both frameworks.

The only thing I am puzzled is to get the minimum and maximum value of an element of a numerical face. As I wish, I do not want to use the parameter and lists of values :

Azure Facet Navigation

My requirement is to display the price facet with the calculated minimum and maximum value. The following website has such a facet in its list of facts:

Price range

In my existing desktop application (.Net), I successfully used BoboBrowse and implemented Custom-FacetHandler to get the desired results, which are shown in the following figure below:

MultiValue facet handler result

Disregard the facet values ​​in these images. These are only the length, height and other characteristic values ​​of the tools.

This is how I create one document for demo purposes. There is a price field that is generated dynamically. Due to the azure search, a strictly fixed scheme is required for each index. I update the schema during the indexing process. It works very well.

Price field

So the question is, how can I achieve the required functionality using azure search?

In elastic search, such a problem can be solved with the help of Aggregations . Does this feature exist in Azure Search?

+7
c # lucene azure-search
source share
1 answer

The $filter parameter supports the lt (less) and gt (more) operators. For example: $filter=price gt 0 and price lt < 100

Code example:

 string PriceFilter(double? fromPrice, double? toPrice) { var filter = "$filter="; if(fromPrice.HasValue) filter+="price gt " + fromPrice.Value.ToString() + (toPrice.HasValue ? " and " : ""); if(toPrice.HasValue) filter+="price lt " + toPrice.Value.ToString(); return filter; } 

Link: Create a filter for the range.

+1
source share

All Articles