Reputation: 81
I'm pretty new to elastic search / NEST and need some help how to be able to query/filter my data.
I have a list of products. And those products can have any number of options with values connected to them. And I need to be able to filter products by the name of the option and it's values.
I've tried to put together a image with the question :)
I don't have the reputation yet to embed images :(
The incoming search/filter parameters is dynamic so there can be any number of options with values.
Hope someone can help me in the right direction!
Thanks!
Upvotes: 1
Views: 2512
Reputation: 81
So after some research and hacking, this is what I came up with and it's working as expected :)
https://i.sstatic.net/bepVX.png
Upvotes: 0
Reputation: 169
var results = client
.Search<YourMappingEntity>(s => s
.Type("page")
.Filter(f => f
.Bool(bb => bb
.Must(ms =>
{
FilterContainer filterContainer = null;
filterContainer &=
ms.Term("Size", yourarrayofsizes) &&
ms.Terms("Color", yourarrayofcolors) ;
return filterContainer;
})))
Upvotes: 1