Developer forum

Forum » Ecommerce - Standard features » Facet values that does not exists

Facet values that does not exists

Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

I have a strange problem with facet values. Values that exists in the FaceOptions loop but not in the database. 

The facet is based on a product category field, with fieldId "Bredd", that is setup as a reference field. 

When I loop through the facet options with facetItem.GetLoop("FacetOptions") I get values that does not exist in the databse. 

We do not have any extenders regarding the index in this solution. And the indexes has been fully reindexed. 

 

One example is "48". 

The DB has some Product Category FIelds with '48' but for other fields. Not 'Bredd'.

Part of a JSON rendered from a productlistfeed template. The value "48" comes from facetOption.GetString("FacetOption.Value")

Anyone else that has experienced these kinds of "ghostvalues"?

Regards / Aki

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

I think we need to see the entire setup.

One thing I can think of is that if a field you use for facets is marked as "Analyzed" a numnber like 48,2 would become 48 and 2 as facets because of the analyzer.

It is also unclear which field you have setup this facet for and how that field looks like in your index and query definition - might helps us to locate the issue.

BR Nicolai

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Good points. 

I just used the field from the SchemaExtender. But I tried to create a new field now with the ProductCategoryFIeld (reference) "Bredd" as source.

The field defintion in settings > ecommerrce. Very simple. 

The field in the repository index :

 

The facet based on the field above:

I am building a "Range facet" but for debugging purposes I just render the values as checkboxes. I also get these strange "0" options with "100" as counts. 

The JSON is rendered with the good old Rapido template: 

                                    foreach (LoopItem facetOption in facetItem.GetLoop("FacetOptions"))
                                    {
                                        string facetLabel = Translate(facetOption.GetString("FacetOption.Label"));

                                        if (facetLabel.ToLower() == "true")
                                        {
                                            facetLabel = Translate("Yes");
                                        }

                                        if (facetLabel.ToLower() == "false")
                                        {
                                            facetLabel = Translate("No");
                                        }

                                        FacetOption facetOptionObject = new FacetOption();
                                        facetOptionObject.template = renderType;
                                        facetOptionObject.name = facetOption.GetString("FacetOption.Name");
                                        facetOptionObject.count = facetOption.GetString("FacetOption.Count");
                                        if (renderType == "Weight") { facetLabel += " " + weightUnit; }
                                        if (renderType == "Range") { facetLabel += " " + currencySymbol; }
                                        facetOptionObject.label = facetLabel;
                                        facetOptionObject.value = facetOption.GetString("FacetOption.Value");
                                        facetOptionObject.queryParameter = facetItem.GetString("Facet.QueryParameter");
                                        facetOptionObject.disabled = facetOption.GetInteger("FacetOption.Count") <= 0 ? "disabled" : "";
                                        facetOptionObject.selected = facetOption.GetBoolean("FacetOption.Selected") ? "checked" : "";
                                        facetGroupObject.FacetOptions.Add(facetOptionObject);

                                        if (facetItem.GetString("Facet.Name") != "Kulör")
                                        {
                                            facetOptionObject.showCount = "1";
                                        }

                                    }

 

 

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Nicolai,

I created a brand new product category field of type Integer called "RefereceTest". Then added it to a product category as a reference field.

I then added some values to different products and created a face based on that field. 

The facet results in values that are not present in the field. To me it looks like the index has problems handling integers?

 

Here is the field. Not analyzed.

Here are the distinct values I added to products in this field. 6 unique values regardless of productcategory. 

Dynamicweb tells me that the term count is 17.

And these are the values that the facetloop produces: 

 

Here is an older post about problem with Integers in the index that never got solved. 

https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/facet-options-for-int32-fields

Can you or sombody confirm that Integers should work as expected in the index/facets or that it does not? 

Regards / Aki

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

If you need to use integers and doubles as facets, you have to index them into a string field - not analyzed.

Lucene stores integers as something bit or byte -ish I do not fully comprehend - and we cannot change it. So simply map the original field from the schema to a string field in the index and you should be good to go.

That is how we hanlde it in Swift facets:

 

If you need the field as part of an expression - i.e. where "weight > 10 and weight < 50" then you need to store it in a seperate field for facets and the expression.

BR Nicolai

 
Aki Ruuskanen
Aki Ruuskanen
Reply

Hi,

thought it was something like that. 

Yes, I need to do "Width > 50" type of facet. 

I'm not sure I follow your suggestion of how to solve inte. Do you mean that I just create a new field in the index ("Width_Facet") with type of Integer and the original field as source? Or how do you mean "store it i a separate field"?

Regards / Aki 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply
This post has been marked as an answer

Width > 50 is technically not a facet - that is an expression.

A facet is a list of terms coming out of the index with counts on how many documents with that term is in the current search result. So if you need a list of all numeric values, you need to index the values as strings.

If you need to do a price range "facet", follow this guide: https://doc.dynamicweb.com/documentation-9/how-tos/general/implementing-a-pricerange-query (From a UI perspective this is not the best option - hard to use, especially on mobile)

Instead you can create price ranges - something like this:

  • Price 
    • 0 - 100 (10)
    • 100-250 (13)
    • 250-500 (23)
    • 500+ (5)

You can achieve that by creating a grouping field in the index - and then use that for a field facet:

https://doc.dynamicweb.com/documentation-9/repositories/indexing/custom-fields#4785

BR Nicolai

Votes for this answer: 1
 
Aki Ruuskanen
Aki Ruuskanen
Reply

OK, thanks for the calrification. I'll take a look at the price range example. 

We will have to dropdowns. One with "From"-values and one with "To"-values so it should be applicable. 

Regards / Aki

 

You must be logged in to post in the forum