문서 검색

GET [인덱스_이름]/_search
POST [인덱스_이름]/_search
GET my_index/_search
{
  "query": {
    "match": {
      "title": "hello"
    }
  }
}
## 결과
{
  "took": 9,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 2,
      "relation": "eq"
    },
    "max_score": 0.8754687,
    "hits": [
      {
        "_index": "my_index",
        "_id": "1",
        "_score": 0.8754687,
        "_source": {
          "title": "hello elasticsearch!!",
          "views": 1234,
          "public": true,
          "created": "2019-01-17T14:05:01/234Z"
        }
      },
      {
        "_index": "my_index",
        "_id": "5wz7rIsBWYO4M4wc3Qko",
        "_score": 0.18232156,
        "_source": {
          "title": "Hello World",
          "views": 1234,
          "public": true,
          "created": "2019-01-17T14:05:01/234Z"
        }
      }
    ]
  }
}

엘라스틱서치는 전문 검색을 지원하는 검색엔진

단순히 주어진 텍스트와 매칭되는 문서를 찾는 것이 아니라 문서를 분석해서 역색인을 만들어 두고 검색어를 분석해서 둘 사이의 유사도가 높은 문서를 찾는 것이다.