Skip to content

Instantly share code, notes, and snippets.

@anuragkh
Last active April 8, 2016 19:18
Show Gist options
  • Save anuragkh/9098b59cb0642e9dd695 to your computer and use it in GitHub Desktop.
Save anuragkh/9098b59cb0642e9dd695 to your computer and use it in GitHub Desktop.
Common elastic search commands
# ** List all indexes, all pretty-like
curl http://localhost:9200/_aliases?pretty=1
# ** Create an index, with specified settings
# Sample settings shown here; creates an index named "wiki"
# with 8 shards. Also creates a mapping called "articles"
# which specifies the index type for its properties ("text",
# "url" and "title") as "not_analyzed".
# See https://www.elastic.co/guide/en/elasticsearch/guide/master/index-doc.html
curl -XPOST localhost:9200/wiki -d '{
"settings" : {
"number_of_shards" : 8
},
"mappings" : {
"articles" : {
"_source" : { "enabled" : false },
"properties" : {
"text" : { "type" : "string", "index" : "not_analyzed" },
"url" : { "type" : "string", "index" : "not_analyzed" },
"title" : { "type" : "string", "index" : "not_analyzed" }
}
}
}
}'
# **View the status of the index, all pretty-like
curl -XGET 'http://localhost:9200/wiki/_status?pretty=1'
# **Index a document
curl -XPUT 'http://localhost:9200/wiki/articles/' -d '{
"title" : "Article",
"url" : "http://en.wikipedia.org/wiki/Article",
"text" : "This is a wikipedia article on articles."
}'
# ** Delete an index
curl -XDELETE 'http://localhost:9200/wiki/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment