I play with Elasticsearch and NEST.
I have some problems understanding various classes and interfaces that can be used to create and create static queries.
Here is a simplified example of what I want to achieve:
using Nest; using System; using System.Text; namespace NestTest { public class Product { public string Name { get; set; } public int Price { get; set; } } public class ProductFilter { public string[] IncludeNames { get; set; } public string[] ExcludeNames { get; set; } public int MaxPrice { get; set; } } class Program { static void Main(string[] args) { var filter = new ProductFilter(); filter.MaxPrice = 100; filter.IncludeNames = new[] { "Notebook", "Workstation" }; filter.ExcludeNames = new[] { "Router", "Modem" }; var query = CreateQueryFromFilter(filter); var client = new ElasticClient();
As you can see, I would like to create some kind of query object (most likely, BoolQuery), and then fill this object later. I have added TODOS code to the code where I have real problems. But in general, there are too many possibilities (IQuery, QueryContainer, XXXQueryDescriptor, SearchDescriptor, SearchRequest), and I cannot figure out how to successfully βassembleβ a part of a query in parts.
Who could enlighten me?
source share