2.X/1. Getting Started

1-01-08. Search with Query DSL

drscg 2017. 10. 1. 12:14

Query-string search is handy for ad hoc searches from the command line, but it has its limitations (see Search Lite). Elasticsearch provides a rich, flexible, query language called the query DSL, whichallows us to build much more complicated, robust queries.

query-string 검색은 command line에서 바로(ad hoc) 검색하기에 편리하다. 하지만 한계가 있다(Search Lite 참조). Elasticsearch는 풍부하고, 유연한, query DSL 이라는 query language를 제공한다. 이것으로 매우 복잡하고 강력한 query를 만들 수 있다.

The domain-specific language (DSL) is specified using a JSON request body. We can represent the previous search for all Smiths like so:

DSL(Domain Specific Language)은 JSON request body를 사용해야 한다. 조금 전의 모든 smith에 대한 검색은 아래처럼 나타낼 수 있다.

GET /megacorp/employee/_search
{
    "query" : {
        "match" : {
            "last_name" : "Smith"
        }
    }
}

This will return the same results as the previous query. You can see that a number of things have changed. For one, we are no longer using query-string parameters, but instead a request body. This request body is built with JSON, and uses a match query (one of several types of queries, which we will learn about later).

이는 조금 전의 query와 동일한 결과를 나타낸다. 여러 가지가 변경된 것을 볼 수 있는데, 그 중 하나는 query-string 매개변수를 더 이상 사용하지 않고, 대신 request body를 사용한다는 점이다. request body는 JSON으로 만들어졌고, match query를 사용한다. match query는 나중에 우리가 배울 여러 가지 query 중의 하나이다.

'2.X > 1. Getting Started' 카테고리의 다른 글

1-01-06. Retrieving a Document  (0) 2017.10.01
1-01-07. Search Lite  (0) 2017.10.01
1-01-09. More-Complicated Searches  (0) 2017.10.01
1-01-10. Full-Text Search  (0) 2017.10.01
1-01-11. Phrase Search  (0) 2017.10.01