<commit_before># Elastica
A flexible chaining API for ElasticSearch

<NAME> 
--------------
Elasticsearch is an amazing tool. However, we find that its request/response payloads to be a little bloated. It is hard to maintain a clean layer to handle your ES requests. This library aims to make it easier to send requests and marshall responses from ES. The current version focuses primarily on querying and marshalling aggregations but we'd like to quickly add more features as we or the community needs them.

Contents
---------
## Request

* [Search](#search)
* [Update](#update)
* [Bulk](#bulk)

## Response

* [Raw](#raw)
* [Hits](#hits)
* [Value Aggregation](#valueAgg)
* [Multi Value Aggregation](#multiValueAgg)
* [Count Aggregation](#countAgg)
* [Multi Count Aggregation](#multiCountAgg)


Installation
------------

`npm install elastica`

Usage
-----

### Initialization

Initialize Elastica with the config you'd typically use in the [ES Javascript API](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html).

```{javascript}
var elastica = require('elastica')(config.es)
```

### Requests

Elastica uses a chained interface to simplify the creation of requests. Every function call returns a new request object. These objects are immutable, and can be saved and reused for convienience. 

<a name="search" />
#### Search

Used to make search queries. All search callbacks pass an [Elastica Response Object](#raw).

##### Examples

__Simple Search__

The simple search use for to describe the document type and in to describe the index range the search takes place in.

```{javascript}
var query = '{"filter": { "term": { "field": "searchValue"} } }'

elastica.search
  .for('myDocType')
  .in('myIndex1,myIndex2')
  .exec(query, function(err, response) {
  })
```

__Search With Compile__

Compiled templates use erb syntax to build the search query.

```{javascript}
var template = '{"filter": { "term": { "field": "<%= myField %>"} } }'

elastica.search
  .for('myDocType')<commit_msg>clarification<commit_after># Elastica
A flexible chaining API for ElasticSearch

<NAME>'être 
--------------
Elasticsearch is an amazing tool. However, we find that its request/response payloads to be a little bloated. It is hard to maintain a clean layer to handle your ES requests. This library aims to make it easier to send requests and marshall responses from ES. The current version focuses primarily on querying and marshalling aggregations but we'd like to quickly add more features as we or the community needs them.

Contents
---------
## Request

* [Search](#search)
* [Update](#update)
* [Bulk](#bulk)

## Response

* [Raw](#raw)
* [Hits](#hits)
* [Value Aggregation](#valueAgg)
* [Multi Value Aggregation](#multiValueAgg)
* [Count Aggregation](#countAgg)
* [Multi Count Aggregation](#multiCountAgg)


Installation
------------

`npm install elastica`

Usage
-----

### Initialization

Initialize Elastica with the config you'd typically use in the [ES Javascript API](http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html).

```{javascript}
var elastica = require('elastica')(config.es)
```

### Requests

Elastica uses a chained interface to simplify the creation of requests. Every function call returns a new request object. These objects are immutable, and can be saved and reused for convienience. Subsequent method calls will not change their state.

<a name="search" />
#### Search

Used to make search queries. All search callbacks pass an [Elastica Response Object](#raw).

##### Examples

__Simple Search__

The simple search use for to describe the document type and in to describe the index range the search takes place in.

```{javascript}
var query = '{"filter": { "term": { "field": "searchValue"} } }'

elastica.search
  .for('myDocType')
  .in('myIndex1,myIndex2')
  .exec(query, function(err, response) {
  })
```

__Search With Compile__

Compiled templates use erb syntax to build the search query.

```{javascript}
var template = '{"filter": { "term": { "field": "<%= myField %>"} } }'

elastica.search
  .for('myDocType')
{'fraction_non_alphanumeric': 0.13059250302297462, 'fraction_numerical': 0.0009673518742442564, 'mean_word_length': 4.434954007884363, 'pattern_counts': {'":': 12, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6825768', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1160, 'n_words': 463}