Mapper-size plugin
출처: 문서
본문
Mapper-size 플러그인
mapper-size 플러그인을 사용하면 OpenSearch 인덱스에서 _size 필드를 사용할 수 있어요. _size 필드에는 각 문서의 크기가 바이트 단위로 저장돼요.
플러그인 설치
다음 명령어를 사용하면 mapper-size 플러그인을 설치할 수 있어요:
./bin/opensearch-plugin install mapper-size
예제
클러스터를 시작한 다음에는, 다음 예제에서 보는 것처럼 size 매핑이 활성화된 인덱스를 만들고, 문서를 색인하고, 문서를 검색할 수 있어요.
size 매핑이 활성화된 인덱스 생성
curl -XPUT example-index -H "Content-Type: application/json" -d '{
"mappings": {
"_size": {
"enabled": true
},
"properties": {
"name": {
"type": "text"
},
"age": {
"type": "integer"
}
}
}
}'
문서 색인
curl -XPOST example-index/_doc -H "Content-Type: application/json" -d '{
"name": "John Doe",
"age": 30
}'
인덱스 쿼리
curl -XGET example-index/_search -H "Content-Type: application/json" -d '{
"query": {
"match_all": {}
},
"stored_fields": ["_size", "_source"]
}'
쿼리 결과
다음 예제에서는 쿼리 결과에 _size 필드가 포함되어, 색인된 문서의 크기를 바이트 단위로 보여줘요:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "example_index",
"_id": "Pctw0I8BLto8I5f_NLKK",
"_score": 1.0,
"_size": 37,
"_source": {
"name": "John Doe",
"age": 30
}
}
]
}
}