데이터 탐색.샘플데이터 집합 로드
* 가상 데이타 생성 : www.json-generator.com/
* 샘플 데이터 : https://github.com/elastic/elasticsearch/blob/master/docs/src/test/resources/accounts.json?raw=true
1) 로드 ( accounts.json )
curl -H "Content-Type: application/json" -XPOST 'localhost:9200/bank/account/_bulk?pretty&refresh' --data-binary "@accounts.json"
curl 'localhost:9200/_cat/indices?v'
2) 검색 API
- GET /bank/_search?q=*&sort=account_number:asc&pretty
-
GET /bank/_search
{
"query": { "match_all": {} },
"sort": [
{ "account_number": "asc" }
]
}
- Query DSL
GET /bank/_search
{
"query": {
"bool": {
"must": [
{ "match": { "title": "Search" }},
{ "match": { "content": "Elasticsearch" }}
],
"filter": [
{ "term": { "status": "published" }},
{ "range": { "publish_date": { "gte": "2015-01-01" }}}
]
}
}
}
3) 쿼리 언어 ( term/ match/ match_phrase )
GET /bank/_search
{
"query": { "match_all": {} }
}
GET /bank/_search
{
"query": { "match_all": {} },
"size": 1
}
GET /bank/_search
{
"query": { "match_all": {} },
"from": 10,
"size": 10
}
GET /bank/_search
{
"query": { "match_all": {} },
"sort": { "balance": { "order": "desc" } }
}
GET /bank/_search
{
"query": { "match_all": {} },
"_source": ["account_number", "balance"]
}
GET /bank/_search
{
"query": { "match": { "account_number": 20 } }
}