[ElasticSearch] copy_to

Woong·2023년 6월 28일
0

ElasticSearch

목록 보기
20/21
  • 필드의 값을 다른 필드에 복사하여, 개별 필드로서 검색 가능하도록 하는 기능
    • _source 에는 나타나지 않음
    • 여러 필드를 한번에 검색하는 케이스가 많은 경우 사용하여 최적화에 활용할 수 있다.
    • analyzer 로 분석된 term 이 아니라 value 그 자체로 복사된다.
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "first_name": {
        "type": "text",
        "copy_to": "full_name" 
      },
      "last_name": {
        "type": "text",
        "copy_to": "full_name" 
      },
      "full_name": {
        "type": "text"
      }
    }
  }
}

PUT my-index-000001/_doc/1
{
  "first_name": "John",
  "last_name": "Smith"
}

GET my-index-000001/_search
{
  "query": {
    "match": {
      "full_name": { 
        "query": "John Smith",
        "operator": "and"
      }
    }
  }
}

reference

0개의 댓글