Developer forum

Forum » CMS - Standard features » Facet outputs products between product two values

Facet outputs products between product two values

Kim Hansen
Reply

Hi there,

I need some help creating a facet, where i enter a value, and the output should show products, where the input value is between two integer product fields (Airflow minimum and Airflow maximum)

So if i enter 50, products with eg. Airflow min = 20 and Airflow max = 100 is listed.

But i cant figure out who to set up the index/query/facet in the backend to make it work.

Have a nice weekend :)

/Kim


Replies

 
Nicolai Pedersen
Reply

Hi Kim

It does not sound like a facet - just a query expression where the search value comes from a field. Like a free text search. I believe you should be able to do it like described in this article:

https://doc.dynamicweb.com/documentation-9/how-tos/general/implementing-a-pricerange-query

Remember to index the field as not analyzed.

BR Nicolai

 
Kim Hansen
Reply

Hi Nicolai,

Hmm.. its a bit the other way around.

I got 2 fields in the backend high and low, and seach by entering one value.

I guess i have to create a Query parameter called Airflow, and 2 expressions like the image below.

But then i dont know how to handle the "facet"

Capture.PNG
 
Nicolai Pedersen
Reply

It is not a facet. It is just an input field.

A facet would give you a list of all values (tokens/phrases) of a field across the entire index - with a count of how many has each token in the search result. Here you hvae 2 fields - and that would give you 2 lists of distinct values from those fields - that makes no sense in your scenario.

So forget facets in this case... Just a parameter and a query expression.

BR Nicolai

 
Kim Hansen
Reply

Im forgetting everything about facets then :)

But lets say i set the query up as above; Air min >= Parameter Airflow and Air max <= Parameter Airflow, then i should be able to write ?airflow=50 in the URL, and get results within the given range, eg products set to min 10 and max 100, right?

Do i need to set up more, because i get zero products back?

Thanks

Kim

 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Kim,

Sorry for interjecting, but it seems to me that the query expressions are the wrong way around. The "Air min" field value should be "LessThanOrEqual" and the "Air max" field value should be "GreaterThanOrEqual", at least if you want the parameter value to be between those field values. Also, I can't tell from the image, but I'd recommend grouping those two expression so it's clear that they belong together.

- Jeppe

Votes for this answer: 1
 
Kim Hansen
Reply

Thanks Jeppe :)

Seems like everything i did was wrong..

Flipped the expression+grouping, set airflow parameter to lowercase, and set it to Int 32

 

You must be logged in to post in the forum