Last active
April 8, 2016 19:18
-
-
Save anuragkh/9098b59cb0642e9dd695 to your computer and use it in GitHub Desktop.
Common elastic search commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ** 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