[ES 공식문서] multi-fields

sisi237·2023년 5월 11일
0

elastic-search

목록 보기
1/5

관련: .mapping 파일
참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html

to index the same field in different ways for different purposes.
This is the purpose of multi-fields.
For instance,

  • a string field mapped as a text field for full-text search,
  • and as a keyword field for sorting or aggregations:
PUT my-index-000001
{
  "mappings": {
    "properties": {
      "city": {
        "type": "text",
        "fields": {
          "raw": { 
            "type":  "keyword"
          }
        }
      }
    }
  }
}

GET my-index-000001/_search
{
  "query": {
    "match": {
      "city": "york" 
    }
  },
  "sort": {
    "city.raw": "asc" 
  },
  "aggs": {
    "Cities": { // my agg name 
      "terms": {
        "field": "city.raw" 
      }
    }
  }
}
profile
자바 서버 개발자

0개의 댓글