provide multiselect facets
When providing a multiselect on the frontend you will need a facet which also provides the non-selected values and their count. The count should than be based on all the other filters, but with the filter on it's own facet ignored.
For instance: You have a country facet which has 6 values:
USA, Canada, Mexico, Brasil, Chile, Argentina
When the user selects USA you send a filter: $filter=country eq USA.
But in the response your facet is now limited to just USA. But since you want to provide a multiselect you also need the other 5 countries in the facet (along with their count).
Could you fix this in the facet setup?
Tip: There is a way of working around this by creating a boolean filter for each of the values in the multiselect. Maybe this helps in fixing the problem.

Thank you all for your feedback. We’re considering this for a future release of Azure Search.
Thanks,
Elad
Azure Search Product Team
15 comments
-
Kris Doyle commented
Throwing my hat into the ring one this one. Client is asking for it.
Thanks!
-
Dave commented
Yes, please! This is essential. See the below page for a good argument as to why.
https://baymard.com/blog/allow-applying-of-multiple-filter-values -
Gavin Barron commented
This is just an any filter isn't it?
document.country = ['USA', 'Canada']
$filter=country/any(c: c eq 'USA')
If you're looking to get a total count for each facet in the first place, why not do an unfiltered search to get the individual facet counts before performing the filter search?
-
Jacques commented
Can't believe that this has not been implemented yet. Not really sure what there is to consider admin.
This is a real issue. -
Nahuel Prieto commented
Very nice idea!
-
George Stanica commented
"Hello, world!" :)
I find this discussion very interesting and of high interest for myself.
I hope my comment will help someone at some point.We applied within our project a working solution for the scenario when our left menu to have a multiselection and/or radio button type behavior instead of the default Azure drill down.
An approach (for now) would be to create multiple specific queries as mentioned below in the following example:Let's suppose we have 100 products produced in different countries, of 3 category types, for men and women. Initially the left menu of the filtering page would look like this:
Country
USA (32)
China (42)
Romania (11)
Germany (15)Category
Clothes (36)
Perfumes (43)
Shoes (21)Type [checkboxes]
For women (50)
For men (50)If the user selects country "Romania" we first calculate the ODATA filter: $sfilter=filtergroup_country/any(t:t eq 'Romania')
We also setup the facets to include all the filter groups which don't have a filter value selected yet.The query parameters will look like this:
$filter=filtergroup_country/any(t:t eq 'Romania')
top=number_elems_per_page
skip=page_number
facet=filtergroup_category,count:1000&facet=filtergroup_type,count:1000where filtergroup_country, filtergroup_category, filtergroup_type are azure fields within
Azure Search items, with assigned filter values.with this first query we'll setup first of all the result items and secondly the counts (and urls) for the filter groups Category and Type, but not for Country for now.
Next, we are going to setup the counts for the Country group, and to do so we'll make another query call to Azure Search with the following parameters:
$filter=empty
top=0
skip=0
facet=filtergroup_country,count:1000This query results will obtain the counts for the Country group as if this filter group hadn't had any of the values selected.
For the following steps the algorithm will function the same, with the observation we can run parallel queries to Azure using TPL in .NET (tasks) and async programming
To continue the example, let's suppose the user clicks on Clothes filter value. So the user will want Clothes produced in Romania.Queries to Azure:
$filter=filtergroup_country/any(t:t eq 'Romania') and filtergroup_category/any(t:t eq 'Clothes')
top=number_elems_per_page
skip=page_number
facett=filtergroup_type,count:1000This query will fill the results items and additionally the counts (and urls) for the Type filter group
The other queries to Azure will fill up the counts (and urls as well) for the Country and Category filter group.
The query to fill the counts for Country
$filter=filtergroup_category/any(t:t eq 'Clothes')
top=0
skip=0
facet=filtergroup_country,count:1000The query to fill the counts for Category
$filter=filtergroup_country/any(t:t eq 'Romania')
top=0
skip=0
facet=filtergroup_category,count:1000As you can see, there are in general the following query types against Azure Search (which could be run in parallel):
1) the first is aimed to generate the effective filtering results + all counts for all the filter values pertaining to filter groups not having any filter value selected
2) a query (with top=0) for each filter group having at least one filter value selected in order to setup only the counts. The $filter for each query must be constructed in such a way as if the processed filter group didn't have any filter value selected, but the rest of the selected filter values from the other filter groups will remain in placeKind Regards,
George -
Anonymous commented
This is a deal breaker for me to start using Azure Search
-
Ant commented
Is this possible yet with Azure search? Elastic search offers post_filter to provide the aggregations before the current filters are applied. And it also allows separate filtering of aggregations.
We desperately need this feature to allow multiple faceted filter selection. Would greatly appreciate any response with how this is achievable in Azure search considering MS won't just expose a managed elastic search product which would be ideal.
Switch to AWS incoming
-
Anonymous commented
Is there any roadmap for tagging / excluding facets? (like in Solr etc.)
-
Anonymous commented
I agree, this is a much needed feature. And I am anxiously waiting for this.
-
RobDavey commented
I agree, this is a much needed feature. Currently we have to work around by making multiple calls to the Index causing more traffic against the azure index.
-
JohnDubya commented
Nearly every major search site - Amazon, NewEgg, Cars.com, etc. - retains all facets upon selecting one of the facet options. This is a highly needed feature.
-
Marcus McConnell commented
I have an account that is concerned they would need to do an "empty" query to retrieve all facets and then keep them locally until multi-select facets are available. This could be up to a 100% increase in the number of queries per second they would need to provision.
-
Ian Nelson commented
Agreed, a filter on a field should be ignored when returning a facet on that field. Else, as Scott and yourself point out, the other options apart from the ones selected will disappear from the facet.
This functionality is often required when developing e.g. e-commerce sites - if the user selects a particular brand from a facet, the other possible brands shouldn't disappear from the list (unless affected by a different facet/filter).
-
Scott commented
This is one of my issues but related to this is we don't get returns of any other values that can be selected for this facet. So in the example above once you select USA as the filter you get no other facets returned for country.