Elasticsearch: Basic Operations Using Postman / Python

Download Postman: https://www.postman.com/downloads/

Create a new index:
PUT http://servername:port/indexname

Delete an index:
DELETE http://servername:port/indexname

Insert data:
POST http://servername:port/indexname
Set header to JSON and enter the below in the body for example:
{"Insturment":"ct5","Mid":999}

Get data:
POST http://servername:port/indexname/_search?size=10000

Get data from python:

import requets
url = 'http://servername:port/indexname/_search?size=1000'
res = requests.get(url)

Insert data from python:

import requets
import json
headers = {"Content-Type":"application/json"}
url = 'http://servername:port/indexname/_doc'
myMsg = {"doc":{"Insturment":"ct5","Mid":100}}
res = requests.post(url, headers=headers, data=json.dumps(myMsg))

Comments

Popular Posts