keyword list형태의 필드를 하나의 string 으로 합쳐 재색인
- reindex 및 script 사용
POST _reindex?wait_for_completion=false
{
"source": {
"index": "keywords"
},
"dest": {
"index": "keywords_to_string"
},
"script": {
"source": """
if (ctx._source.kwd != null) {
StringBuilder combinedValues = new StringBuilder();
for (item in ctx._source.kwd) {
combinedValues.append(item);
combinedValues.append(" ");
}
ctx._source.str = combinedValues.toString().trim();
ctx._source.remove('kwd');
}
""",
"lang": "painless"
}
}
keywords 인덱스에 keyword list 형태로 적재되어있는 kwd 필드를 하나의 string으로 합쳐서 keywords_to_string 인덱스의 str 필드로 적재
- script 옵션 이용해 string 생성 코드 작성
- 스페이스(" ")로 구분자 적용
- 기존 kwd 필드 제거 필요할 경우 remove 이용해 제거
'Elasticsearch' 카테고리의 다른 글
Elasticsearch 디스크 불균등 이슈 해결하기 (0) | 2024.03.10 |
---|---|
nested list field size 집계 (1) | 2023.12.23 |
NGram analyzer (0) | 2023.12.14 |
Elasticsearh Enrich processor (1) | 2023.10.28 |
ElasticSearch(oss) vs OpenSearch (0) | 2023.10.28 |