'Querying elastic search with linq using NEST
Is there any way to query Elasticsearch with NEST client using linq or lambda expressions.
I Want to do somthing like this :
client.Search<MyClass>(s => s.MyProperty.Contains("value") &&
(s.MySecondProperty == 123 ||
s.ThirdProperty > 12)) ;
Or
var query = from m in MyContext.MyClass
where ...
select m
I read a little about ElasticLinq but it seems that it is no more active. the last nuget package were published on october 2015
What i want to do is to create a method that get an Expression as parameter from the caller and search on elastic with it. the caller should not depend on ES or NEST API
Solution 1:[1]
The exact query you write there today works just great in ElasticLINQ.
The project is still alive - just sometimes there is no reason for a new release. There was a point release today to fix a corner case in generating Queries (not filters) using OR's nested within an AND.
Solution 2:[2]
I am currently working on the LINQ query provider library to generate NEST method calls. If someone is interested - here is the link to the GitHub repository - https://github.com/VladislavRybnikov/NEST.Linq
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Vladyslav |
