ElasticSearchLite.NetCore 1.3.0.2

A simple .NET wrapper for ElasticSearch.Net

There is a newer version of this package available.
See the version list below for details.
Install-Package ElasticSearchLite.NetCore -Version 1.3.0.2
dotnet add package ElasticSearchLite.NetCore --version 1.3.0.2
<PackageReference Include="ElasticSearchLite.NetCore" Version="1.3.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ElasticSearchLite.NetCore --version 1.3.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Synopsis

A simple .NET Core wrapper for ElasticSearch.Net

Wiki Page

Wiki

Code Example

Connecting to a node(s)

var client = new ElasticLiteClient("http://myserver:9200", "http://myserver:9201");

Implement IElasticPoco interface for your pocos.

public class MyPoco : IElasticPoco
{
    public string Id { get; set; }
    public string Type { get; set; }
    public string Index { get; set; }
    public double? Score { get; set; }
    public Tag Tag { get; set; }
    public Position Position { get; set; }
    public string Name { get; set; }
    public DateTime LastModified { get; set; }
}
public class Tag
{
    public string Name { get; set; }
    public string Summary { get; set; }
}
public class Position
{
    public double X { get; set; }
    public double Y { get; set; }
}

Query Examples

Search Example

After creating a new ElasticLiteClient object, you can build up your Search object which requires an index to use the Search API from ElasticSearch. After this the search can be specified with different methods like: Term, Match, Range, Sort, Take, Skip.

var client = new ElasticLiteClient("http://myserver:9200");

// Term query example
var pocosFoundWithTerm = Search
    .In("mypocoindex")
    .Return<MyPoco>()
    .Term(p => p.Name, "ABCDEFG")
    .Sort(p => p.LastModified, ElasticSortOrders.Descending)
    .Take(20)
    .Skip(0)
    .ExecuteWith(client);
    
// Match query example
var pocosFoundWithMatch = Search
    .In("mypocoindex")
    .Return<MyPoco>()
    .Match(p => p.Name, "ABCD EFGH")
    	.Operator(ElasticOperators.Or)
    .Sort(p => p.LastModified)
    	.ThenBy(p => p.Score, ElasticSortOrders.Descending)
    .ExecuteWith(client);

Index Example

The add a document to ElasticSearch using a POCO object, the POCO will require the index and type name which will be used by the Index API from ElasticSearch. After the request is completed the poco's Id property will be updated if it hasn't been set in the before the request, in which case the given Id will be set in ElasticSearch.

var client = new ElasticLiteClient("http://myserver:9200");
var poco = new MyPoco 
{ 
    Index = "mypocoindex", 
    Type = "mypoco", 
    Name = "ElasticSearch is awesome!",
	LastModified = DateTime.Now()
};

Index.Document(poco)
    .ExecuteWith(client);

Update Example

Update can be used to persist POCO changes to ElasticSearch as in seen in this example below. The POCO does require a valid Id property. That also goes for Index and Type like previously.

var client = new ElasticLiteClient("http://myserver:9200");
poco.LastModified = DateTime.UtcNow;

Update
    .Document(poco)
    .ExecuteWith(client);

Delete POCO Example

Delete will remove one existing document from ElasticSearch when it's constructed from a POCO.

var client = new ElasticLiteClient("http://myserver:9200");

var deleteDocuments = Delete
    .Document(poco)
    .ExecuteWith(client);

Delete Query Example

Delete can also be used as a query to remove multiple documents from ElasticSearch if necessary.

var client = new ElasticLiteClient("http://myserver:9200");

var deleteDocuments = Delete
    .From("mypocoindex")
    .Documents<MyPoco>()
    .Term(p => p.Name, "ABCDEFG")
    .ExecuteWith(client);

Synopsis

A simple .NET Core wrapper for ElasticSearch.Net

Wiki Page

Wiki

Code Example

Connecting to a node(s)

var client = new ElasticLiteClient("http://myserver:9200", "http://myserver:9201");

Implement IElasticPoco interface for your pocos.

public class MyPoco : IElasticPoco
{
    public string Id { get; set; }
    public string Type { get; set; }
    public string Index { get; set; }
    public double? Score { get; set; }
    public Tag Tag { get; set; }
    public Position Position { get; set; }
    public string Name { get; set; }
    public DateTime LastModified { get; set; }
}
public class Tag
{
    public string Name { get; set; }
    public string Summary { get; set; }
}
public class Position
{
    public double X { get; set; }
    public double Y { get; set; }
}

Query Examples

Search Example

After creating a new ElasticLiteClient object, you can build up your Search object which requires an index to use the Search API from ElasticSearch. After this the search can be specified with different methods like: Term, Match, Range, Sort, Take, Skip.

var client = new ElasticLiteClient("http://myserver:9200");

// Term query example
var pocosFoundWithTerm = Search
    .In("mypocoindex")
    .Return<MyPoco>()
    .Term(p => p.Name, "ABCDEFG")
    .Sort(p => p.LastModified, ElasticSortOrders.Descending)
    .Take(20)
    .Skip(0)
    .ExecuteWith(client);
    
// Match query example
var pocosFoundWithMatch = Search
    .In("mypocoindex")
    .Return<MyPoco>()
    .Match(p => p.Name, "ABCD EFGH")
    	.Operator(ElasticOperators.Or)
    .Sort(p => p.LastModified)
    	.ThenBy(p => p.Score, ElasticSortOrders.Descending)
    .ExecuteWith(client);

Index Example

The add a document to ElasticSearch using a POCO object, the POCO will require the index and type name which will be used by the Index API from ElasticSearch. After the request is completed the poco's Id property will be updated if it hasn't been set in the before the request, in which case the given Id will be set in ElasticSearch.

var client = new ElasticLiteClient("http://myserver:9200");
var poco = new MyPoco 
{ 
    Index = "mypocoindex", 
    Type = "mypoco", 
    Name = "ElasticSearch is awesome!",
	LastModified = DateTime.Now()
};

Index.Document(poco)
    .ExecuteWith(client);

Update Example

Update can be used to persist POCO changes to ElasticSearch as in seen in this example below. The POCO does require a valid Id property. That also goes for Index and Type like previously.

var client = new ElasticLiteClient("http://myserver:9200");
poco.LastModified = DateTime.UtcNow;

Update
    .Document(poco)
    .ExecuteWith(client);

Delete POCO Example

Delete will remove one existing document from ElasticSearch when it's constructed from a POCO.

var client = new ElasticLiteClient("http://myserver:9200");

var deleteDocuments = Delete
    .Document(poco)
    .ExecuteWith(client);

Delete Query Example

Delete can also be used as a query to remove multiple documents from ElasticSearch if necessary.

var client = new ElasticLiteClient("http://myserver:9200");

var deleteDocuments = Delete
    .From("mypocoindex")
    .Documents<MyPoco>()
    .Term(p => p.Name, "ABCDEFG")
    .ExecuteWith(client);

Release Notes

- Added the missing types to utilize the aggregation functions.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.3.1 505 6/11/2018
1.3.0.2 192 5/15/2018
1.3.0.1 172 5/14/2018
1.3.0 226 5/13/2018
1.2.2 379 12/2/2017
1.2.1.2 619 12/1/2017
1.2.1.1 338 11/20/2017
1.2.1 275 11/9/2017
1.2.0 262 10/13/2017
1.1.2 626 9/15/2017
1.1.1 278 9/10/2017
1.1.0.2 328 8/31/2017
1.1.0.1 297 8/30/2017
1.1.0 269 8/28/2017
1.0.7.1 294 8/25/2017
1.0.7 326 8/25/2017
1.0.6 284 8/17/2017
1.0.5.1 300 8/1/2017
1.0.5 290 8/1/2017
1.0.4 314 7/31/2017
1.0.3 374 7/27/2017
1.0.2 319 7/21/2017
1.0.1 305 7/19/2017
1.0.0 314 7/19/2017
0.9.9 366 7/11/2017
0.9.8 329 7/7/2017
0.9.7 299 7/5/2017
0.9.6 312 7/4/2017
0.9.5 319 6/29/2017
0.9.4 293 6/28/2017
0.9.3 333 6/2/2017
0.9.2 343 5/29/2017
0.9.1 294 5/23/2017
0.9.0 402 5/22/2017