In [1]:
import json

import elasticsearch
from elasticsearch import Elasticsearch

es_server = 'http://search-01.ec2.internal:9200/'
indice = 'schiefjm_sng_logs'
es = Elasticsearch([es_server])
es


Out[1]:
<Elasticsearch([{u'host': 'search-01.ec2.internal', u'scheme': 'http', u'port': 9200}])>

In [58]:
create_body = json.dumps({
    "mappings": {
        "log_entry": {
            "properties": {
                "data": {
                    "properties": {
                        "point": { "type": "geo_point" },
                        "RSV_IP_ADDRESS": { "type": "ip", "store": "true" },
                        "destIP": { "type": "ip", "store": "true" },
                        "BBOX_WKT": { "type": "geo_shape" },
                        "BBOX_WKT2": { "type": "geo_shape" }
                    }
                }
            }
        }
    }
})

es.indices.delete(index=indice)
es.indices.create(index=indice, body=create_body)


Out[58]:
{u'acknowledged': True}

In [59]:
es.indices.get_mapping(indice)


Out[59]:
{u'schiefjm_sng_logs': {u'mappings': {u'log_entry': {u'properties': {u'data': {u'properties': {u'BBOX_WKT': {u'type': u'geo_shape'},
       u'BBOX_WKT2': {u'type': u'geo_shape'},
       u'RSV_IP_ADDRESS': {u'store': True, u'type': u'ip'},
       u'destIP': {u'store': True, u'type': u'ip'},
       u'point': {u'type': u'geo_point'}}}}}}}}

In [27]:
es.index(index=indice, doc_type="log_entry", body=body)


Out[27]:
{u'_id': u'AUxxQoreN3YTQcbSD53T',
 u'_index': u'schiefjm_sng_logs',
 u'_type': u'log_entry',
 u'_version': 1,
 u'created': True}

In [ ]: