In one of my categories have products ranging in price from £21.54 - £165.00. When calling the below code the price Facet contains 5 Facet Values, 3 of which have 0 Hits.
SearchLibrary.GetFacetsFor(category, facets)
What I'd expect to happen here, is the Price Facet would only return Facet Values that have hits > 0, and the price ranges would correspond to the products in that category. One of the Facet Values with 0 hits had a price range of £1548 - £1602 which is a lot higher than anything in that category.
I've tried editing the Search.config file to be like below, but now I just get 30 Facet Values returned, 28 with 0 hits (still only 2 actually have values):
Thanks for the response. We are already filtering out the facets with zero hits, what I was hoping to find is a way of returning price Facets with ranges in the category being searched for.
The price facet ranges returned seem to be for the entire site and not just the category I'm querying against. The prices for items in my website range from £1.80 to £1400 so when querying against the entire product set getting very wide price ranges make sense, these are the ranges retrieved:
£0 - £161
£160 - £321
£320 - £481
£801 - £962
£1281 - £1442
However when querying against a specific category that only has products with prices in the range £10.76 - £44.10 only 1 price facet that has hits is returned:
£0 - £161
Is this a bug or by design? If it's by design is there a way of overriding this behavior to get something like this:
This is by design. The reason for this is that the ranges are determined by the facet itself, which means that they're defined globally.
You could change the facet to include more ranges with a narrower scope and dynamically change the number returned when you know which ranges are available.
Price facet returns
In one of my categories have products ranging in price from £21.54 - £165.00. When calling the below code the price Facet contains 5 Facet Values, 3 of which have 0 Hits.
SearchLibrary.GetFacetsFor(category, facets)
What I'd expect to happen here, is the Price Facet would only return Facet Values that have hits > 0, and the price ranges would correspond to the products in that category. One of the Facet Values with 0 hits had a price range of £1548 - £1602 which is a lot higher than anything in that category.
I've tried editing the Search.config file to be like below, but now I just get 30 Facet Values returned, 28 with 0 hits (still only 2 actually have values):
Hi Chris,
This behavior is by design so you have to choice of display facets with zero hits or not.
If you don't want them you can filter the return facets based on the number of hits before displaying.
There's an example in Avenue Clothing on how to this:
https://bitbucket.org/uCommerce/ucommerce-razor-store/src/e2f4b535c423165cd4dc20810b2f817693f482dd/src/uCommerce.RazorStore/macroScripts/uCommerce/Facets.cshtml?at=default
Hope this helps.
Hi Soren,
Thanks for the response. We are already filtering out the facets with zero hits, what I was hoping to find is a way of returning price Facets with ranges in the category being searched for.
The price facet ranges returned seem to be for the entire site and not just the category I'm querying against. The prices for items in my website range from £1.80 to £1400 so when querying against the entire product set getting very wide price ranges make sense, these are the ranges retrieved:
However when querying against a specific category that only has products with prices in the range £10.76 - £44.10 only 1 price facet that has hits is returned:
Is this a bug or by design? If it's by design is there a way of overriding this behavior to get something like this:
Thanks
This is by design. The reason for this is that the ranges are determined by the facet itself, which means that they're defined globally.
You could change the facet to include more ranges with a narrower scope and dynamically change the number returned when you know which ranges are available.
Hope this helps.
is working on a reply...