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

Try our conversational search powered by Generative AI!

MatchContained yields no results

Vote:
 

Using the Search with GetContentResult, I have a convention for the Product:

public static List<string> SizesOfShoe(this ProductContent product) =>
    ProductService.GetVariantsOrEmpty(product.ContentLink).Select(Size.ShoeSize).Select(x => x.Value).ToList();

That is applied as a convention:

conventionBuilder.IncludeField(x => x.SizesOfShoe());

Now, when I just use the TermsFacetFor(x => x.SizesOfShoe()) then I get proper results and TermsFacets has all the options with proper counts.

However, when I want to filter by the ShoeSize then I end up with no results.

The filter I'm creating is as following:

if (Criteria.ShoeSizes?.Any() ?? false)
{
    var filter = client.BuildFilter<ClientProduct>();
    foreach (var size in Criteria.ShoeSizes) filter = filter.Or(x => x.SizesOfShoe().MatchContained(y => y, size));
    q = q.Filter(filter);
}

ShoeSizes in Criteria is an IEnumerable<string>.

Am I doing something wrong? Case sensitivity is not an issue here since I'm dealing with numbers here (which are under strings).

#286910
Edited, Sep 09, 2022 10:56
Vote:
 

try 

q = q.Filter(x=> x.SizesOfShoe().In(Criteria.ShoeSizes, true))
#286911
Sep 09, 2022 11:29
Vote:
 

Yes, Farhana, that works like a charm, thank you!

#286912
Sep 09, 2022 11:33
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.