100 Days of DevOps — Day 84-Introduction to ElasticSearch

java >7
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.2.zip$ unzip elasticsearch-5.4.2.zip$ cd elasticsearch-5.4.2# To start ElasticSearch$ bin/elasticsearch
$ curl http://localhost:9200{
“name” : “ASEUJl9”,
“cluster_name” : “elasticsearch”,“cluster_uuid” : “LSEdI1HARj-O_cSk0k8DLg”,“version” : {“number” : “5.4.2”,“build_hash” : “929b078”,“build_date” : “2017–06–15T02:29:28.122Z”,“build_snapshot” : false,“lucene_version” : “6.5.1”},“tagline” : “You Know, for Search”}
$ wget https://artifacts.elastic.co/downloads/kibana/kibana-5.4.2-darwin-x86_64.tar.gz$ tar -xvf kibana-5.4.2-darwin-x86_64.tar.gz$ cd kibana-5.4.2-darwin-x86_64$ vim config/kibana.ymlNow go inside kibana.yml and uncomment this entryelasticsearch.url: "http://localhost:9200"# Start Kibana$ bin/kibana
Kibana
Kibana: Data VisualizationElasticSearch: Store,Index,Search and Analyze dataLogstash,Beats: Data IngestionX-Pack: Additional Features
# Adding Index$ curl -XPUT http://localhost:9200/testing{"acknowledged":true,"shards_acknowledged":true}# Getting all indices in a cluster$ curl -XGET http://localhost:9200/_cat/indices?vhealth status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.sizeyellow open   testing Zkhf_-5pR2yPvjvqgdLlyg   5   1          0            0       650b           650byellow open   test    rfTZJwiSTSmufAzzHWjSkg   5   1          0            0       650b           650byellow open   .kibana 8-5xFao6TjCqV3a_iNCFnw   1   1          1            0      3.1kb          3.1kb# Get a specific index in a cluster$ curl -XGET http://localhost:9200/testing?pretty{"testing" : {"aliases" : { },"mappings" : { },"settings" : {"index" : {"creation_date" : "1498323861381","number_of_shards" : "5","number_of_replicas" : "1","uuid" : "Zkhf_-5pR2yPvjvqgdLlyg","version" : {"created" : "5040299"},"provided_name" : "testing"}}}}
  • When Index is created by default it’s assigned to 5 primary shards(fixed)
  • There is a one replica shard(can be changed any time)
index --> my_index
type --> my_doc
document --> 1
Fields -->
"name":"testuser",
"years":1,
"date":"2017-06-24"
$ curl -XGET http://localhost:9200/my_index?pretty
{
“my_index” : {“aliases” : { },“mappings” : {“my_doc” : {“properties” : {“date” : {“type” : “date”},“name” : {“type” : “text”,“fields” : {“keyword” : {“type” : “keyword”,“ignore_above” : 256}}},“years” : {“type” : “long”}}}},“settings” : {“index” : {“creation_date” : “1498325421498”,“number_of_shards” : “5”,“number_of_replicas” : “1”,“uuid” : “upg2ElNdTHGpcCPCOMb6AA”,“version” : {“created” : “5040299”},“provided_name” : “my_index”}}}}
name: stringdate: date
$ curl -XGET http://localhost:9200/_cat/indices?vhealth status index uuid pri rep docs.count docs.deleted store.size pri.store.sizeyellow open testing Zkhf_-5pR2yPvjvqgdLlyg 5 1 0 0 650b 650byellow open my_index upg2ElNdTHGpcCPCOMb6AA 5 1 1 0 4.4kb 4.4kbyellow open my_new_test qcwTmf7VSbiutHfZOJSlZw 1 2 0 0 130b 130byellow open test rfTZJwiSTSmufAzzHWjSkg 5 1 0 0 795b 795byellow open .kibana 8–5xFao6TjCqV3a_iNCFnw 1 1 1 0 3.1kb 3.1kb
$ curl -XDELETE http://localhost:9200/test{“acknowledged”:true}
$ curl -XGET http://localhost:9200/_cluster/health?pretty{“cluster_name” : “elasticsearch”,“status” : “yellow”, # It shows yellow because it's single node cluster“timed_out” : false,“number_of_nodes” : 1,“number_of_data_nodes” : 1,“active_primary_shards” : 12,“active_shards” : 12,“relocating_shards” : 0,“initializing_shards” : 0,“unassigned_shards” : 13,“delayed_unassigned_shards” : 0,“number_of_pending_tasks” : 0,“number_of_in_flight_fetch” : 0,“task_max_waiting_in_queue_millis” : 0,“active_shards_percent_as_number” : 48.0}
  • We can add a document without assign an id, ElasticSearch by default assign id for us(we need to use POST for this purpose)
  • Optionally we can assign id using PUT(But if the same id exist, ElasticSearch will throw 409 conflict error)
  • Allow us to index multiple documents at one time
curl -XPOST http://localhost:9200/books/_bulk --data-binary @test.json

--

--

--

AWS Community Builder, Ex-Redhat, Author, Blogger, YouTuber, RHCA, RHCDS, RHCE, Docker Certified,4XAWS, CCNA, MCP, Certified Jenkins, Terraform Certified, 1XGCP

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

js211 — blogPost_206

Dxn Code Strike Reviews, Price, Side Effects, Ingredients, Scam

DevOps Tool Comparison: Docker Vs Kubernetes Vs Ansible

Day142 — path to iOS developer

Login as root in Kali

SDET Survival Guide — Designing a Test

Ruby Play Network Airdrop

Returning Home, After an Amazon Internship

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prashant Lakhera

Prashant Lakhera

AWS Community Builder, Ex-Redhat, Author, Blogger, YouTuber, RHCA, RHCDS, RHCE, Docker Certified,4XAWS, CCNA, MCP, Certified Jenkins, Terraform Certified, 1XGCP

More from Medium

OpenShift Local Lab Setup on RHEL VM

AWS-Part 12

Keep on learning with DevOps!

100 Days of K8s — Namespaces & Services.