<commit_before># ElasticMapping

A simple mapping builder for Elasticsearch.<commit_msg>doc update<commit_after># ElasticMapping

A _simple_ mapping builder for Elasticsearch.


## Synopsis

```py
from elasticmapping import ElasticMapping
from elasticmapping.types import STRING, INTEGER, FLOAT

# An mapping which forms an ES doc_type
class DocMapping(ElasticMapping):
    __doc_type__ = 'doc_mapping'

    # Top-level attributes
    name = STRING
    ID = INTEGER

    # Nested documents
    nested_document = Nest(
        float_type=FLOAT,
        interger_type=INTEGER
    )

# Print out JSON ready for ES
print DocMapping.json(indent=4)
```

Check out the [full example](./example/mapping.py).


## Types

+ `STRING`
+ `BOOLEAN`
+ `FLOAT`, `DOUBLE`, `INTEGER`, `LONG`, `SHORT`, `BYTE`
+ `DATE` (format = `date`), `DATETIME` (format = `date_hour_minute_second`)


## Queries/Searches

ElasticMapping can be combined with my other ES library, [ElasticQuery](https://github.com/Fizzadar/ElasticQuery). When ElasticQuery is provided mappings, it limits the fields it can search/aggregate on to that of the mapping - this helps to prevent unexpected errors. For more details see the [query example](./example/query.py).
{'fraction_non_alphanumeric': 0.10081967213114754, 'fraction_numerical': 0.000819672131147541, 'mean_word_length': 4.402654867256637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, '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': '5840273', 'n_tokens_mistral': 378, 'n_tokens_neox': 364, 'n_words': 121}