Index and Document
- Index and Document
- The process of inserting data/documents is called as indexing
- Lets refer the elastic search rest api’s Refer Here
- Refer Here for index apis
- Lets create curl request to create the index
ESPASS='nplUwdODeH4xtPfp=CT2'
SERVER_URL='https://20.198.70.188:9200'
# Checking if the index exists
curl -I -u elastic:$ESPASS "${SERVER_URL}/sample" --insecure
# we got 404 response => index not found
* Lets create one more index with
* name: sample2
* number of shards 1
* number of replicas 1
Exercise:
- Create an index with yourname
- Check if the index exists or not
- delete the index
- The commands used are
curl -I -u elastic:$ESPASS "https://20.198.70.188:9200/khajaibrahim?pretty" --insecure
curl -X DELETE -u elastic:$ESPASS "https://20.198.70.188:9200/khajaibrahim?pretty" --insecure
curl -I -u elastic:$ESPASS "https://20.198.70.188:9200/khajaibrahim?pretty" --insecure
- Now let me insert a document about Devops
{
"name": "DevOps",
"tools": ["Git", "Ansible", "Jenkins", "Docker", "K8s", "Terraform", "SRE"]
}
- The curl request is
curl -X POST -u elastic:$ESPASS "https://20.198.70.188:9200/khajaibrahim/_doc?routing=kimchy&pretty" -H 'Content-Type: application/json' --insecure -d'
{
"name": "DevOps",
"tools": ["Git", "Ansible", "Jenkins", "Docker", "K8s", "Terraform", "SRE"]
}
'