Skip to content

ElasticSearch NEST Linq extension library which provides possibility to use LINQ over NEST elastic queries.

License

Notifications You must be signed in to change notification settings

VladislavRybnikov/NEST.Linq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NEST.Linq

ElasticSearch NEST Linq extension library which provides possibility to use LINQ over NEST elastic queries.

  1. Search example using LINQ extension methods:
client // Nest.IElasticClient instance
    .AsQueryable<User>()
    .Where(u => u.Name == "Vlad")
    .Skip(5)
    .Take(10)
    .Search();

This code will be converted to next query using NEST fluent syntax:

client.Search<User>(s => s
    .From(5)
    .Size(10)
    .Query(q => q
        .Match(m => m
            .Field(f => f.Name)
            .Query("Vlad"))));
  1. Search example using LINQ query syntax:
var users = (
    from user in client.AsQueryable<User>()
    where user.Name.StartsWith("V")
    where user.Name == "Vlad"
    select user).Search();
  1. Also, this LINQ syntax could be easily integrated with existing NEST queries, if there are some specific logic which could not be described in LINQ syntax.
client
    .AsQueryable<User>()
    .Skip(5)
    .Take(10)
    .Search(s => s
        .Query(q => q
            .Match(m => m
                .Field(f => f.Name).Query("Vlad"))));

Consider the difference between NEST and NEST.ElasticallyQuariable filter requests

NEST NEST.ElasticallyQuariable
.Bool(b => b.Should(l => l.Match(m => m.Field(f => f.Name).Query("Alice")), l => l.Match(m => m.Field(f => f.Name).Query("Bob")))) .Where(u => u.Name == "Alice" || u.Name == "Bob")

About

ElasticSearch NEST Linq extension library which provides possibility to use LINQ over NEST elastic queries.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages