sudo README

Posts


No results for 'undefined'

Notes


No results for 'undefined'

Elasticsearch

Useful Elasticsearch commands,

# List indices
curl -sX GET "localhost:9200/_cat/indices?v&s=index&pretty"
# Create index
curl -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 mapping
curl -sX PUT "localhost:9200/my-index/_mapping" \
-H 'Content-Type: application/json' \
-d'{
"dynamic": "false",
"date_detection": false,
"numeric_detection": false,
"properties": {
...
}
}
'
# Delete index
curl -X DELETE "localhost:9200/my-index?pretty"
# Query multiple properties where k2 is a text and keyword property
curl -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 all
curl -X GET "localhost:9200/my-index/_search?pretty" \
-H 'Content-Type: application/json' \
-d'{
"query": {
"match_all": {}
}
}
'

Rocky Warren's blog. Principal Architect, Tech Lead, Product Manager. I do other stuff too.

ResumeNotesPhotos