Developer forum

Forum » CMS - Standard features » Nex Index - grouping field with Double

Nex Index - grouping field with Double

Nuno Aguiar
Reply

Hi,

 

We were trying to create a grouping filed to be used as a price range, but noticed the grouping field only seemed to work with Strings. Is this accurate?

http://screencast.com/t/0LBWkHu1

 

Best Regards,

Nuno Aguiar


Replies

 
Carsten Boll
Reply

Hi Nuno,

If you're looking to do a regular price range search, check out this how-to on range-based filtering in Ecommerce:
 

 
Nuno Aguiar
Reply

Hi Carsten,

 

I am looking for a regular price range, but my products are so big that when we use the Price field as a facet, it takes an additional 1 second, that's why we want to use a Grouping field.

 

Did you manage to make it work with a grouping field?

 

Best Regards,

Nuno Aguiar

 
Nicolai Høeg Pedersen
Reply

Grouping field is instead of range. So what you are trying to does not make that much sense...

Making a facet on price field is the same as "Group By Price" which makes no sense in facets.

So your search for the price range is like a free text search - just criterias and parameters, no facet in the backend. (It might be rendered with the facets frontend, but it is not a facet)

So you would have 2 parameters FromPrice and ToPrice that are used on 2 different criterias on the search (Price "greater than" FromPrice and Price "Less than" ToPrice)

In your facets in the frontend you would have a slider, 2 fields or whatever to specify the 2 parameter values.

So your challenge is to get the lowest and highest price in the current result set...

BR Nicolai

 
Nuno Aguiar
Reply

Hi Nicolai,

 

We were expecting to use the "Between" operator, but we can use 2 parameters and use the "greater than" and the "lower than" operators.

 

And you are right, my challenge is to get the lowest and highest price in the current result set. We'll hard code it

 

Best Regards,

Nuno Aguiar

 
Nicolai Høeg Pedersen
Reply

You can also use between. But you still do not have to group the prices and make a facet.

When you use grouping, you store all products in the price range 500-1000 as 500 in the index, so it will not make sense to use grouping with between.

Grouping is used for grouping values so they can be used as facets. So all products priced < 500 is in one group, all products priced 500-1000 is in another group etc.

Then you make just a regular facet on top of that, giving you a facet like this:

0-500 (12)
500-1000 (17)
1000-5000 (9)

Makes sense?

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Yes it makes sense, and I was actually using grouping accurately, example:

  • Instead of "0-500" I used the value "0"
  • Instead of "500-1000" I used the value "500"
  • Instead of "1000-5000" I used the value "1000"

 

My idea with this was to get something like (using your example amounts)

  500 (12)
  1000 (17)
  5000 (9)

 

Sorting the options (500 , 1000 , 5000) would also get me the lowest (0) and the maximum (highest option - in this case 5000) and build a price slider. Understandingly it would not be 100% accurate.

 

Anyhow the problem is that when we build the instance with the grouping field as System.Double, it does not seem to work, only when it's System.String. We can still index it as a string and in Razor try to parse it as a number and get the highest number.

 

And all this to avoid creating 2 free text parameters and facets (PriceFrom and PriceTo), and still have a performant product list page (because we would use a grouping field and not the price as a facet).

 

Not sure I got my message through accurately, but putting it in here at least helped me :)

 

Best Regards,

Nuno Aguiar

 

You must be logged in to post in the forum