공부용

ES(ElasticSearch) Select/GET/SEARCH 예제 본문

공부용

ES(ElasticSearch) Select/GET/SEARCH 예제

고딕짱! 2021. 5. 6. 15:41

#SELECT DATABASE

localhost/_cat/indices?v

localhost/_cat/indices?v

 

 

URL 처리 예제

-----------------------------

#GET/SELECT/SEARCH DATA

GET localhost/index/type/_search?""?filter_path=...

GET localhost/index/type/_search?""&filter_path=...

- index : database

- type : table

- _search?q="" - > 연관단어? 들어간단어 다 긁어온다

 

- _search?q="" 사용법

"columnA":"rowA" AND "columnB":"rowB"

- columnA에 있는 rowA와 columnB에 있는 rowB를 공동으로 가지고 있는걸 들고 오겠다

 

- filter_path 사용법

- json으로 받은 서식에서, 어떤 정보만 받아오겠다

-- select columnA, columnB from table(type);

 

 

* 최종

GET localhost/index/type/_search?"columnA:AAA"&filter_path=columnA

sql로 정리하자면

selet columnA from table(type) where columnA like 'AAA';

 

 

 

* comment(최근수정 : 2021/05/05 - 15:40pm) 

지극히 개인적인 생각입니다. 공부를 더 해보고 수정해야할 사항이 있으면 수정하겠습니다

 

*참고사이트

www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html

 

REST APIs | Elasticsearch Guide [7.12] | Elastic

We are working on including more Elasticsearch APIs in this section. Some content might not be included yet.

www.elastic.co

victorydntmd.tistory.com/312?category=742451

 

[Elasticsearch] 입문하기(2) - 기본 API( index, document CRUD )

1. Index, Type, Document 이전 글에서 Cluster에 대해 알아보았습니다. Cluster는 node들의 집합이고 노드는 shard로 구성되며, 데이터는 shard로 분산되어 저장합니다. Index는 1개 이상의 primary shard에 매..

victorydntmd.tistory.com

 

DSL Query 처리예제

--------------------------------

GET tpye/_search?
{
  "_source": ["field1", "field2"],
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "field" : "data"
          }
        }
      ]
    }
  }

 

원하는 필드만 출력할 수 있다

sql : select field1, field2 from type where field = "data";

'공부용' 카테고리의 다른 글

[ElasticSearch] AND / OR  (0) 2021.05.10
[ElasticSearch] term, match, match_phrase  (0) 2021.05.10
Comments