Why mapping isn't woking with python Elasticsearch?

I need to map lat, long to geo-point. I stream data every 10 seconds from a website. I get only first occurrence of the "position" from json and only I take lat, long and timestamp. I did mapping and when I run my code the data is streaming but can't see the mapping in Kibana.

Here is my code.

import time,schedule
import requests
from elasticsearch import Elasticsearch 
import warnings
import sys
import logging
import json

log_format = "%(asctime)s::%(levelname)s::%(name)s::"\
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=log_format)

URL = "https://www.n2yo.com/rest/v1/satellite/positions/25544/41.702/-76.014/0/2/&apiKey=key"

def connectES():
	es = Elasticsearch('http://ip:port',timeout=600)
	logging.info('Step 1: Connect to Elasticsearch: OK!!')
	return es
es = connectES()

settings = {
             'settings': {
              'mappings': {
es.indices.create(index = "satellitepositions", ignore = 400, body=settings)

def collect_data():
  data = requests.get(url = URL).json() 
  del data['positions'][1]
  my_dict["satlatitude"]= data["positions"][0]["satlatitude"]
  my_dict["satlongitude"]= data["positions"][0]["satlongitude"]
  my_dict["timestamp"]= data["positions"][0]["timestamp"]

  new_data = json.dumps(my_dict)
  es.index(index='satellitepositions', doc_type='satelitepos', body=new_data)
  logging.info('Step 2: Data streaming and saving to Elasticsearch : OK!!')

while True:

Output in Kibana:

Can some one tell me where the my error is...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.