StoryCode

데이터 탐색.샘플데이터 집합 로드

Elastic Search
반응형

* 가상 데이타 생성 : www.json-generator.com/

* 샘플 데이터 : https://github.com/elastic/elasticsearch/blob/master/docs/src/test/resources/accounts.json?raw=true

accounts.json
0.23MB

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 } }
}

 

 

 

 

반응형

'Elastic Search' 카테고리의 다른 글

KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30
모든 색인 나열/ 생성  (0) 2019.04.28
매뉴얼-https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html  (0) 2019.04.28
클러스터 상태 보기  (0) 2019.04.28