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!
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;
})))
So after some research and hacking, this is what I came up with and it's working as expected :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.