PYCON OTTO
elasticsearch-py | example
In [1]: from elasticsearch import Elasticsearch
In [2]: es = Elasticsearch()
In [3]: es.indices.create(index='emails', ignore=400)
Out[3]: {'acknowledged': True, 'shards_acknowledged': True}
In [4]: es.index(index="emails", doc_type="email", id=4, body={})
Out[4]:
{'_id': '4', '_index': 'emails', '_shards': {'failed': 0, 'successful': 1, 'total': 2},
'_type': 'email', '_version': 1, 'created': True, 'result': 'created'}
In [5]: es.get(index="emails", doc_type="email", id=4)['_source']
Out [5]:
{'Abstract': 'Cara Elena, ho rivisto la norma operativa i...', 'Body': 'Cara Elena, some text
here…..', 'Categories': '', ... ,'Subject': 'Rev norma operativa parti correlate'}
{
"Abstract": "Cara Elena, ho rivisto",
"Body": "Cara Elena, some text here…..",
"Categories": "",
"CopyTo": [
"
[email protected]"
],
…
}