Elasticsearch
Useful Elasticsearch commands,
# List indicescurl -sX GET "localhost:9200/_cat/indices?v&s=index&pretty"# Create indexcurl -X PUT "localhost:9200/my-index?pretty" \-H 'Content-Type: application/json' \-d'{ "settings": { "number_of_shards": 1, "number_of_replicas": 1 }, "mappings": { "dynamic": "false", "date_detection": false, "numeric_detection": false, "properties": { "k1": { "type": "keyword" }, "k2": { "type": "text", "fields": { "k": { "type": "keyword" } } } }}'# Update index mappingcurl -sX PUT "localhost:9200/my-index/_mapping" \-H 'Content-Type: application/json' \-d'{ "dynamic": "false", "date_detection": false, "numeric_detection": false, "properties": { ... }}'# Delete indexcurl -X DELETE "localhost:9200/my-index?pretty"# Query multiple properties where k2 is a text and keyword propertycurl -sX GET "localhost:9200/my-index/_search?pretty" \-H 'Content-Type: application/json' \-d'{ "query": { "bool": { "must": [{ "term": { "k1": { "value": "val-1" } } }, { "term": { "k2.k2": { "value": "val-2" } } }] } }}'# Match allcurl -X GET "localhost:9200/my-index/_search?pretty" \-H 'Content-Type: application/json' \-d'{ "query": { "match_all": {} }}'