Developer forum

Forum » Ecommerce - Standard features » Using reference fields for queries and facets

Using reference fields for queries and facets

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

I have a project where I want to use reference fields for ProductCategory fields for the purpose of optimizing Facet definitions.

I have defined them in a Reference ProductCategory and reused them in additional regular ProductCategories.

I have also assigned values for the fields.

I am now in the process of defining the Query and Facet.

First, I have defined one Parameter for each Reference field.

The documentation here: https://doc.dynamicweb.com/documentation-9/ecommerce/product-catalog/custom-fields#sideNavTitle1-3 mentioned that I can use the reference fields as Facets. Which is cool. But it does not say if I should also use them in the Query.

Therefore my question is: Should I use the Reference fields in the Query or the Regular fields? If I have to use the regular fields, will this have a major impact on performance? Should I group all fields tied to a Parameter in an expression?

Thank you,

Adrian

 

 


Replies

 
Nicolai Pedersen
Reply

I would guess the regular field - that would have no major impact on performance. You should not group them - that would give you a minor performance hit.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I have tried with and without Grouping into Expressions.

With Expression grouping, it works. Without grouping, it does not.

https://gf.dotfusion.ro/products

"Brand" is defined individually, each instance of the product category field with its own expression while "Tip produs" is defined as an "Or" expression encapsulating all fields using the same parameter.

"Brand" does not work, while "Tip Produs" works.

I am wondering what am I doing wrong.

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

I was too soon to speak :)

Neither one of them works :)

Back to the drawing board,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I have set the "Do not analyze default fields" to true and now it seems that my aaumption is correct:

"Brand" does not work, while "Tip Produs" works.

It is probably related to the fact that multiple query expressions are tied to the same Parameter. Or I am doing something wrong.

I have also noticed that any change made to the query will require a reindex. I am not sure if this is a new feature or I have misconfigured anything. I don't remember that a reindex was needed after a change in the query.

And I am using DW 9.9.4

Thank you,

Adrian

 
Nicolai Pedersen
Reply

Changing the query does not require a rebuild... That would not make any sense - or even be possible for us to change it to work like that.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

I understand that. It seemed weird to me as well.

Probably a misconfiguration on my end.

I have tried several options but without the enclosing Expression, it does not seem to work when having multiple expressions using the same parameter.

Adrian

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply

Hi Adrian,

I am willing to disclose the situation, but to make sure we are on the same page, could you confirm that I understood the problem correctly:
you have some reference field called Brand which is referenced by 2 categories and have values on e.g. 2 different products. And on the frontend you expecting by using facet(and query) set-up on field from system category get those 2 products found by selecting the facet, right?

BR, Viktor.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Vicktor,

Thank you for your reply.

Here is the simplified setup.

2 separate ProductCategories. Each of them having a Brand property. Each Brand property is tied to a Brand Reference field.

In the Query, I have defined a Brand Parameter that is supposed to be used for both of these fields.

In the Facet, I have defined a Facet based on the Brand Reference field and the Brand Parameter.

The remaining question is how should I define the Query expressions?

I have tried defining 2 separate expressions inside the generic "And" Group Expression:

ProductCategory|ProductCategory1|Brand   In  Brand (Parameter)

ProductCategory|ProductCategory2|Brand   In  Brand (Parameter)

This approach did not seem to work. Probably because the presence of the Brand parameter triggered both expressions into something like this:

ProductCategory|ProductCategory1|Brand in Brand AND ProductCategory|ProductCategory2|Brand in Brand which will obviously render 0 results as there will be no product belonging to both ProductCategories.

Then, I tried grouping the above expressions in a GroupExpression using OR.
And this approach worked.

I have no problem going forward with this approach if there is no alternative option that would be more efficient than this one.

Please let me know if my explanation is lacking clarity.

Thank you,

Adrian

 

 

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply

Hi Adrian,

I've set-up my solution to have same scenario, and I can see that it is actually possible to set-up query expression based on the system category field to have all the referenced field values match on facet. see https://www.screencast.com/t/nJtS1SzaFa4

P.S. I had some cahing issues related to creating/changing category & their product values - not everything was dysplayed correctly in the repositories such as schema extender doesn't display newly created system field and the facet field selector, but IIS reset solved the problem. Also I have "SkipCategoryFields" set to "False" and "HandleInheritedCategoryValues" set to "True" in the index builder settings, make sure you have them enabled same way.

BR, Viktor.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Viktor,

Thank you very much for the explanation.

Have you also tried using different values for the Brand property? Like MyBrand and MyBrand1 ?

Thank you,
Adrian

 
Viktor Letavin Dynamicweb Employee
Viktor Letavin
Reply

Hi,

did just now, works as expected, see https://www.screencast.com/t/6I3mAHcw

BR, Viktor.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Viktor,

It looks pretty good.

I will try it on my end and see what happens.

Thank you,
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Viktor,

I have made a testing on my own and it kinda works but something strange is happening and I cannot explain it.

Here is a video: https://www.screencast.com/t/zj5kLfWY

What I have done is this:

1. I have removed my previously defined expressions

2. I have created an expression using the Brand reference field

3. Tested. Nothing works

4. Reindexed

5. Tested again. It works

6. Saved the Query

7. Tested again. It does not work anymore

8. Maximum confusion. Record video

 

Please tell me you can make any sense of it. In case you want to test it for yourself, the link is https://gf.dotfusion.ro/

I am using DW 9.9.4

Thank you,
Adrian

 

You must be logged in to post in the forum