In Conversation with ELK Hands-On| Part2

  • Installation of ES.
  • Mappings in ES.
  • Field Analysers.
  • Bulk Data Ingestion.
  • Document Immutability behaviour into ES.
  • Ingest documents into ES.
  • Partial document update basis of documentId using POST verbatim.
  • Full document update basis of documentId using PUT verbatim.
  • Delete a document from ES.
curl --location --request PUT 'http://localhost:9200/_cluster/settings' \
--header 'Content-Type: application/json' \
--data-raw '{
"persistent": {
"ingest.geoip.downloader.enabled": true
}
}'
curl --location --request PUT 'http://localhost:9200/_cluster/settings' \
--header 'Content-Type: application/json' \
--data-raw '{
"persistent": {
"ingest.geoip.downloader.enabled": false
}
}'
curl --location --request PUT 'localhost:9200/movies' \
--header 'Content-Type: application/json' \
--data-raw '{
"mappings": {
"properties": {
"year" : {
"type" : "date"
}
}
}
}'
  • standard was split on word boundaries.
  • simple splits on anything that isn’t a letter and converts to lowercase.
  • simple whitespace just splits on whitespace but doesn’t convert to lowercase.
curl --location --request PUT 'localhost:9200/movies/_doc/109487' \
--header 'Content-Type: application/json' \
--data-raw '{
"genre" : ["Sci-Fi", "IMAX"],
"title" : "Interstellar",
"year" : 2014
}'
curl --location --request GET 'localhost:9200/movies/_search'
  • hit.total.value of 1 means, there are net 1 records, found in our Index.
  • hits array indicates the records into ElasticSearch.
{
"took": 121,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "movies",
"_type": "_doc",
"_id": "109487",
"_score": 1.0,
"_source": {
"genre": [
"Sci-Fi",
"IMAX"
],
"title": "Interstellar",
"year": 2014
}
}
]
}
}
{ "create" : { "_index" : "movies", "_id" : "135569" } }
{ "id": "135569", "title" : "Star Trek Beyond", "year":2016 , "genre":["Action", "Adventure", "Sci-Fi"] }
{ "create" : { "_index" : "movies", "_id" : "122886" } }
{ "id": "122886", "title" : "Star Wars: Episode VII - The Force Awakens", "year":2015 , "genre":["Action", "Adventure", "Fantasy", "Sci-Fi", "IMAX"] }
{ "create" : { "_index" : "movies", "_id" : "109487" } }
{ "id": "109487", "title" : "Interstellar", "year":2014 , "genre":["Sci-Fi", "IMAX"] }
{ "create" : { "_index" : "movies", "_id" : "58559" } }
{ "id": "58559", "title" : "Dark Knight, The", "year":2008 , "genre":["Action", "Crime", "Drama", "IMAX"] }
{ "create" : { "_index" : "movies", "_id" : "1924" } }
{ "id": "1924", "title" : "Plan 9 from Outer Space", "year":1959 , "genre":["Horror", "Sci-Fi"] }
curl --location --request PUT 'localhost:9200/_bulk' \
--header 'Content-Type: application/json' \
--data-binary '@/Users/B0218162/Documents/LEARNINGS/MEDIUM-BLOG/ElasticSearch/ml-latest-small/movies.json'
curl --location --request POST 'localhost:9200/movies/_doc/109487/_update' \
--header 'Content-Type: application/json' \
--data-raw '{
"doc":{
"title":" Space Interstellar"
}
}'
curl — location — request GET ‘localhost:9200/movies/_search?q=trek’
curl — location — request DELETE ‘localhost:9200/movies/_doc/135569’

--

--

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
aditya goel

aditya goel

Software Engineer for Big Data distributed systems