Developer forum

Forum » Ecommerce - Standard features » Facet for Rating

Facet for Rating

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I was trying to set up a facet for Rating based on the standard Rating field on the product.

I tried several options but ended up nowhere because it looks like the values in the index are somehow broken.

Just to be sure it's not my version that's causing the issue, I have tried it on the official Demo solution: http://dynamicwebdemo.dwsales.dynamicweb-cms.com/products/bikes/mountain-bikes

The attached screenshot shows what is returned for the Rating field. I guess the field is indexing different content than just rating.

If there is another way of accomplishing this Rating facet behavior, please let me know.

 

Thank you,
Adrian

 

rating-facet.png

Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

Try to to create a custom index field of type string where the source is the rating to get it to work and use that instead.

 

Best Regards,

Nuno Aguiar

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nuno,

Already tried that. It solves the facets but you will not be able to filter if some product has an aggregated rating of 4.5 because you cannot create a rule of "Greater than.."

Ideally, this should be working like a PriceRange.

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Any other option? Is this issue fixed in newer versions?

Adrian

 
Nicolai Pedersen
Reply

The normal recommendation is to index numbers as strings and pad them with 0s:

000000001
000000011
000000002

etc. Then you can do an order by or greater than using strings.

In this case you have to do something custom in order to make it work - either pad and remove commas or round all ratings down to nearest integer and index that information.

BR Nicolai

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you for the suggestion. I want to avoid customizations as much as possible.

I suppose this happens for any field that has a numeric value.

Is this something you plan on fixing in newer versions?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

I have no good solution for it as it is right now...

Come to think of it - you can used grouping fields:

https://doc.dynamicweb.com/documentation-9/platform/indexing-search/indexes#sideNavTitle1-4-3

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

That's exactly what I am trying to do. But I cannot create a range if the values are strings, right?

Ratings will almost always be double and I would like to create 4-5 groups:

  • below 1 star
  • 1-2 stars
  • 2-3 stars
  • 3-4 stars
  • more than 4 stars

But if the values will not be handled as numbers, I cannot do that, right?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

The facet grouping field works for numbers - thats the entire idea of them... So yeah, it should work for ratings.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I tried that approach first but it did not seem to work. that's how I ended up listing the Rating directly.

If you say it should work, I will give it another try.

And just so I understand correctly, I cannot use a numeric field as a facet if I won't render it as a string, but I can use a numeric field in Grouping fields, right?

Thank you,
Adrian

 
Nicolai Pedersen
Reply

Hi Adrian

If you look at the documentation and the first screen dump in the link above, you can see exactly how to do this. In that example the price which is a double, is grouped using a string group field.

BR Nicolai

 
Nicolai Pedersen
Reply

And you cannot use dates and numeric fields directly as facets.

 

You must be logged in to post in the forum