Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Building Term Facet For JSON object

Vote:
 

Hi All ,

Hope you are all doing well . 

I have been facing an issue to build a Term facet . 

My JSON object in FIND index will be like below

 "FilterAttributes": {
        "thredcount": "100",
        "colour": "blue",
        "Size": "small"
    }

I am using the below code to build the Term Facet

 .TermsFacetFor(x=>x.FilterAttributes.Root.Values(),x=>x["colour"].ToString(),x=>x.Name="colour")

unfortunately its not working as I expected .  Term Facet count always zero.

Expected result : 

blue (1)

Request you all to let m eknow what worng woth my code.

CMS Version 11

Commerce Version 11

Find version 13

Regards

Venkata Phani kumar R

#191205
Apr 24, 2018 3:18
Vote:
 

Looks like FilterAttribues is a property of some type in Newtonsoft.Json?

I would either convert FilterAttributes to a real C# property based on a custom class or something like a Dictionary<string, string>().

#191460
Apr 24, 2018 22:19
Vote:
 

Hi John,

Thanks for your reply .

As you mentioned I have converted the Property into Dictonary Property .

 "FilterFacetValues": {
        "Values": [
            "small",
            "100",
            "red"
        ],
        "colour$$string": "red",
        "thredcount$$string": "100",
        "$type": "System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]",
        "Size$$string": "small",
        "Keys": [
            "Size",
            "thredcount",
            "colour"
        ]
    }


buliding termfacet like this  .TermsFacetFor(x=>x.FilterFacetValues["colour"]).

Its working .

Thanks for your help and advice.


Regards
Venkata Phani kumar R
#191522
Apr 25, 2018 1:45
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.