본문 바로가기

내가 당면한 문제와 해결방안

elasticsearch6.7 index 만들기 with mapping + reindex + alias

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings

 

Create index API | Elasticsearch Reference [7.5] | Elastic

Before 7.0.0, the mappings definition used to include a type name. Although specifying types in requests is now deprecated, a type can still be provided if the request parameter include_type_name is set. For more details, please see Removal of mapping type

www.elastic.co

 

그냥 만들어도 되는데, 필드가 geo_shape 로 매핑되어야한다면. 해야하는 작업.

 

1) 만들고자 하는 인덱스 이름 with mapping definition을 전송.

 

2) host get하면 version check 할 수 있으니. 그것 확인 후에. 나의 경우에는 6.7 이므로.

 

https://www.elastic.co/guide/en/elasticsearch/reference/6.7/indices-put-mapping.html

여기 확인해서....

 

 

 

 

PUT https://호스트/만들고자 하는 인덱스 이름/_mapping/doc

 

{
  "properties": {
    "boundaries": { 
      "type": "geo_shape",
      "ignore_malformed": true,
      "precision": "1.0m",
      "strategy": "recursive",
      "distance_error_pct": 0.009
    }
  }
}

 

 

2 이제 reindex 해야댐 헠헠

 

POST _reindex { "source": { "index": "twitter" }, "dest": { "index": "new_twitter" } }

 

 

3 alias

POST /_aliases
{
    "actions" : [
        { "add" : { "index" : "expedia_migrated_poi_20191203_3", "alias" : "expedia_poi" } }
    ]
}

 

 

참고 

https://www.elastic.co/guide/en/elasticsearch/reference/6.7/mapping.html

https://www.elastic.co/guide/en/elasticsearch/reference/6.7/indices-put-mapping.html

https://www.elastic.co/guide/en/elasticsearch/reference/6.7/docs-reindex.html 

https://www.elastic.co/guide/en/elasticsearch/reference/6.7/indices-aliases.html