Try our conversational search powered by Generative AI!

How to build facet based on a specific object in a lists of complex objects

Vote:
 

Here is my indexed object:

{    
    "Prices": [
        {
            "Price$$number": 31.5,
            "MarkedId$$string": "Market1"
        },
        {
            "Price$$number": 12,
            "MarkedId$$string": "Market2"
        }
    ],
    "FinalPrice$$number": 31.5
}

The requirement is to build price facets based on the price value in the current user market.

I was able to build the facet basd on the FinalPrice value using this line of code:

var SearchFacetPriceRangesResult = searchFacetQueryPrice.RangeFacetFor(x => x.FinalPrice, priceRanges.ToArray())GetResult();

How can I achieve the same in complex objects.

Thanks in advance.

#121520
May 13, 2015 0:32
Vote:
 

Hi,

To search/filter on complex objects you can use https://github.com/x2find/Nested2Find/ (also available on the EPiServer nuget feed). The published version doesn't support nested faceting but there is a feature branch (https://github.com/x2find/Nested2Find/tree/nested-facets) that you can pull and build yourself that currently supports terms/histogram facets for nested objects (see https://github.com/x2find/Nested2Find/blob/nested-facets/Nested2Find.Tests/Stories/Nested.cs#L295 for usage).

/Henrik


#121545
Edited, May 13, 2015 12:28
Vote:
 

Thanks Henrik!

I will give it a try and let you know.

Do you have a plan to support Find versions > 9.0 ?

#121553
May 13, 2015 16:46
Vote:
 

I was able to select the nested field Price. However, all nested prices are being selected for Ranges.

I am looking for sending only the Price that exists in the current user market.

How can I add a filter for a selected nested field?

#121595
Edited, May 14, 2015 16:34
Vote:
 

There is no facet filter support in the nested-facet feature branch as of yet.

/Henrik 

#121823
May 18, 2015 15:16
Vote:
 

Thanks Henrik for your reply.

To overcome this issue, I had to index the prices in a dictionary object.

#121830
May 18, 2015 16:44
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.