본문 바로가기

카테고리 없음

[Elasticsearch] mapping

### Elasticsearch Mapping Exam


  • 기존 mapping에 새로운 필드를 추가하는것은 가능하나 기존의 설정을 변경하는것은 불가능하다. 원한다면 다음 절차대로 해야한다.
    • 해당 type의 데이터를 모두 삭제한다.
    • 새 매핑을 입력한다.
    • 데이터 전체를 다시 색인한다.
  • 이유는 기존 매핑 타입과 다른 타입으로 업데이트를 할 경우 (ex. "string" -> "Long") 문제가 생기기 때문.


1. 현재 mapping 상태 확인

- curl 'localhost:9200/get-together/_mapping/new-events?pretty'


2. mapping 추가

- 기존 매핑에 병합된다.

curl -XPUT 'localhost:9200/get-together/_mapping/new-events' -d ' {
    "new-events" : {
        "properties" : {
            "host" : {
                "type" : "string"
            }
        }
    }

}'


3. analyzer

curl -XPUT 'localhost:9200/get-together/_mapping/new-events?pretty' -d ' {

"new-events" : {

"properties" : {

"name" : {

"type" : "string",

"index" : "not_analyzed"

}

}

}

}'