$ curl -X GET "http://localhost:9200/"
$ curl -X GET "http://localhost:9200/_cat/health?v"
$ curl -X PUT "http://localhost:9200/products/_settings?pretty" -H 'Content-Type: application/json' -d '
{
"index.blocks.read_only_allow_delete": null
}'
$ curl -X GET "http://localhost:9200/_cat/indices?v"
$ curl -X PUT "http://localhost:9200/products?pretty"
$ curl -X PUT "http://localhost:9200/soccers?pretty"
$ curl -X DELETE "http://localhost:9200/soccers?pretty"
$ curl -X GET "http://localhost:9200/products/_doc/1"
$ curl -X PUT "http://localhost:9200/products/_doc/2" -H 'Content-Type: application/json' -d'
{
"fullname": "Duc Toan",
"age": 30
}'
$ curl -X PUT "http://localhost:9200/products/_doc/2" -H 'Content-Type: application/json' -d'
{
"fullname": "Duc Toan",
"age": 30,
"subject": [
"toan",
"van",
"anh"
]
}'
$ curl -X DELETE "http://localhost:9200/products/_doc/2"
$ curl -X POST "http://localhost:9200/_bulk?pretty" -H 'Content-Type: application/json' --data-binary "@opt/vietnam-football.json"
$ curl -X POST "http://localhost:9200/accounts/_bulk?pretty" -H 'Content-Type: application/json' --data-binary "@opt/accounts.json"
$ curl -X GET "http://localhost:9200/accounts/_search?pretty"
$ curl -X GET "http://localhost:9200/accounts/_search?pretty=true&q=*:*"
# Seach match_all (_source, sort, size, from)
$ curl -X GET "http://localhost:9200/accounts/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {"match_all": {}},
"_source": ["account_number", "balance"],
"sort": [
{
"balance": {
"order": "desc"
}
}
],
"size": 2,
"from": 10
}'
# Seach match (age)
$ curl -X GET "http://localhost:9200/accounts/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {"match": {
"age": 34
}},
"_source": ["account_number", "balance", "age"],
"sort": [
{
"balance": {
"order": "desc"
}
}
],
"size": 2,
"from": 10
}'
# Search logic (must, should, must_not)
$ curl -X GET "http://localhost:9200/accounts/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"should": [
{"match": {"address": "mill"}},
{"match": {"address": "lane"}}
],
"must_not": [
{"match": {"state": "IL"}}
]
}
},
"_source": ["account_number", "balance", "address", "state"],
"sort": [
{
"balance": {
"order": "desc"
}
}
]
}'