2014-12-17 5 views
1

필드에 대한 기존 매핑이 있으며이를 다중 필드로 변경하려고합니다.ElasticSearch 업데이트 다중 필드 매핑

기존의 매핑은 documentation을 바탕으로

{ 
    "my_index": { 
     "mappings": { 
     "my_type": { 
      "properties": { 
       "author": { 
        "type": "string" 
       }, 
       "isbn": { 
        "type": "string", 
        "analyzer": "standard", 
        "fields": { 
        "ngram": { 
         "type": "string", 
         "search_analyzer": "keyword" 
        } 
        } 
       }, 
       "title": { 
        "type": "string", 
        "analyzer": "english", 
        "fields": { 
        "std": { 
         "type": "string", 
         "analyzer": "standard" 
        } 
        } 
       } 
      } 
     } 
     } 
    } 
} 

, 나는 다음과 같은

PUT /my_index 
{ 
    "mappings": { 
     "my_type": { 
      "properties": { 
       "author": 
       { 
        "type": "multi-field", 
        "fields": { 
         "ngram": { 
          "type": "string", 
          "indexanalyzer": "ngram_analyzer", 
          "search_analyzer": "keyword" 
         }, 
         "name" : { 
         "type": "string" 
         } 
        } 
       }    
      } 
     } 
    } 
} 

을 실행하여 다중 필드에 "저자"를 변경할 수있을 것입니다하지만 그 대신 내가 얻을 다음 오류 :

{ 
"error": "IndexAlreadyExistsException[[my_index] already exists]", 
"status": 400 
} 

정말 실종 된 항목이 있습니까? 대신/my_index에 PUT의

+0

PUT 대신 POST를 시도 할 수 있습니까? –

+0

PUT은 좋지만 오류 상태로 이미 색인이 존재하므로 기존 색인의 매핑을 변경할 수 없습니다. 그것을 삭제 한 다음 새로운 매핑으로 생성해야합니다. 해당 인덱스에 보관할 데이터가있는 경우 스캔 및 스크롤 API를 사용하여 데이터를 다른 인덱스로 이동 한 다음 my_index를 삭제하고 새 매핑으로 데이터를 만들고 데이터를 my_index로 다시 이동하십시오 –

+0

[juliendangers] (http://stackoverflow.com/users/1478667/juliendangers). 하지만 필자가 연계 한 Elastic 문서에서 다중 필드 매핑을 추가 할 때 할 수 있다고 말한 이유에 대해 혼란 스럽습니다. ** 모든 스칼라 필드 (즉, 유형 객체 필드 또는 중첩 필드 제외)는 다중 필드로 업그레이드 될 수 있습니다 다시 색인하지 않고 put_mapping API ** – maurocam

답변

1

는 수행

POST /my_index/_mapping 
+1

대신이 오류가 발생했습니다 : 유효성 검사 실패 : 1 : 매핑 유형이 누락; –

0

당신은 이미 기존 인덱스의 필드 유형을 변경할 수 없습니다. 색인을 다시 만들 수없는 경우 사본 필드를 사용하여 비슷한 기능을 얻을 수 있습니다.

PUT /my_index 
     { 
      "mappings": { 
      "my_type": { 
     "properties": { 
        "author": 
        { 
         "type": "string", 
         "copy_to": ["author-name","author-ngram"] 
        } 

        "author-ngram": { 
         "type": "string", 
         "indexanalyzer": "ngram_analyzer", 
         "search_analyzer": "keyword" 
        }, 
        "author-name" : { 
        "type": "string" 
        } 

      }    
      } 
     } 
    } 
    } 
1

특정 예제에서 시도하지는 않았지만 실제로 인덱스를 닫은 다음 매핑을 적용하여 필드 매핑을 업데이트 할 수 있습니다.

예 : 나는 매핑 필드에 "copy_to"매핑 속성을 추가하여, 그것을 테스트 한

POST /my_index/_close 
POST /my_index/_mapping 
{ 
    "my_field:{"new_mapping"} 
} 
POST /my_index/_open 

.

https://gist.github.com/nicolashery/6317643 기준.