<commit_before># FluentNest

| Elastic Search & Nest Version | Build | Nuget  |
| ------------- |:-------------:| :-----:|
| 1.7.* and greater| [![Build 2.0.0](https://ci.appveyor.com/api/projects/status/wrorpoekyw416hn1/branch/master?svg=true)](https://ci.appveyor.com/project/hoonzis/fluentnest) | [![Nuget Package](https://img.shields.io/nuget/v/fluentnest.svg)](https://www.nuget.org/packages/fluentnest) |
| 2.0.* and greater| [![Build 2.0.0](https://ci.appveyor.com/api/projects/status/wrorpoekyw416hn1/branch/2.0.0?svg=true)](https://ci.appveyor.com/project/hoonzis/fluentnest)|[![Nuget Package](https://img.shields.io/badge/nuget-v1.0.116-blue.svg)](https://www.nuget.org/packages/FluentNest/1.0.166) |

LINQ-like query language for ElasticSearch built on top of NEST.

NEST for querying ElasticSearch is great, but complex queries are hard to read and reason about. The same can be said about the basic JSON ElasticSearch query language. This library contains set of methods that give you more LINQ-like feeling. Currently mainly aggregations and filters are covered. This page contains few examples, more details are available in the [wiki](https://github.com/hoonzis/fluentnest/wiki/FluentNest-wiki). Motivation and few more implementation details are described in [this blog post.](http://www.hoonzis.com/fluent-interface-for-elastic-search/).

### Statistics
```Csharp
var result = client.Search<Car>(search => search.Aggregations(agg => agg
	.SumBy<Car>(x => x.Price)
	.CardinalityBy(x => x.EngineType)
);

var priceSum = result.Aggs.GetSum<Car, decimal>(x => x.Price);
var engines = result.Aggs.GetCardinality<Car>(x => x.EngineType);
```

Since all the queries are always done on the same entity type, one can also convert the result into a typed container:

```Csharp
var container = result.Aggs.AsContainer<Car>();
var priceSum = container.GetSum(x => x.Price);<commit_msg>updating the table of the readme to reflect the current state of the branches<commit_after># FluentNest

LINQ-like query language for ElasticSearch built on top of NEST, aimed at simplifying analytical queries. Compatible with ElastichSearch 1 and 2.

| Elastic Search & Nest Version | Build | Nuget | Branch |
| ------------- |:-------------:| :-----:|
| 1.7.* and greater| [![Build 2.0.0](https://ci.appveyor.com/api/projects/status/wrorpoekyw416hn1/branch/1.0.0?svg=true)](https://ci.appveyor.com/project/hoonzis/fluentnest) | [![Nuget Package](https://img.shields.io/badge/nuget-v1.0.116-blue.svg)](https://www.nuget.org/packages/FluentNest/1.0.166) | [1.0.0](https://github.com/hoonzis/fluentnest/tree/1.0.0) |
| 2.0.* and greater| [![Build 2.0.0](https://ci.appveyor.com/api/projects/status/wrorpoekyw416hn1?svg=true)](https://ci.appveyor.com/project/hoonzis/fluentnest)|[![Nuget Package](https://img.shields.io/nuget/v/fluentnest.svg)](https://www.nuget.org/packages/fluentnest) | [master](https://github.com/hoonzis/fluentnest/) |

NEST for querying ElasticSearch is great, but complex queries are hard to read and reason about. The same can be said about the basic JSON ElasticSearch query language. This library contains set of methods that give you more LINQ-like feeling. Currently mainly aggregations and filters are covered. This page contains few examples, more details are available in the [wiki](https://github.com/hoonzis/fluentnest/wiki/FluentNest-wiki). Motivation and few more implementation details are described in [this blog post.](http://www.hoonzis.com/fluent-interface-for-elastic-search/).


### Statistics
```Csharp
var result = client.Search<Car>(search => search.Aggregations(agg => agg
	.SumBy<Car>(x => x.Price)
	.CardinalityBy(x => x.EngineType)
);

var priceSum = result.Aggs.GetSum<Car, decimal>(x => x.Price);
var engines = result.Aggs.GetCardinality<Car>(x => x.EngineType);
```

Since all the queries are always done on the same entity type, one can also convert the result into a typed container:

```Csharp
var container = result.Aggs.AsContainer<Car>();
var priceSum = container.GetSum(x => x.Price);
{'fraction_non_alphanumeric': 0.15819489213984628, 'fraction_numerical': 0.017356806347632037, 'mean_word_length': 4.503410641200546, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 20, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '274055', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1306, 'n_words': 330}