# Mtermvectors 쿼리 결과를 새로운 인덱스에 저장할 수 있나요?

**URL:** <https://discuss.elastic.co/t/mtermvectors/74273>\
**Category:** 한국어 질문 및 토론\
**Created:** [February 7, 2017, 7:29pm UTC](https://discuss.elastic.co/t/mtermvectors/74273 "2017-02-07T19:29:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yungyoung\_Ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yungyoung_ok/32/43465_2.png) [@Yungyoung\_Ok](https://discuss.elastic.co/u/Yungyoung_Ok)\
**Post date:** [February 7, 2017, 7:29pm UTC](https://discuss.elastic.co/t/mtermvectors/74273/1 "2017-02-07T19:29:07Z")

</div>

현재 mtermvectors 쿼리를 이용해서 단어별 점수 합계를 구하는 작업을 진행 중입니다.

1. mtermvectors 결과 확인
2. 결과를 새로운 인덱스에 저장(nested 형태로 변경)
3. 새로운 인덱스를 가져와서 어그리게이션 작업

위의 세 가지 작업을 하나의 쿼리만으로 동시에 할 수 있나요?

현재 제 쿼리 같이 올립니다.  
세 단계로 나누어진 작업을 한 단계로 줄이고 싶어요.

1. mtermvectors query  
GET /\_mtermvectors?pretty=true  
{  
"docs":[  
{  
"\_index": "je\_test",  
"\_type": "je\_tweet",  
"\_id": "2",  
"fields":["contents"],  
"offsets":false,  
"payloads":false,  
"positions":false,  
"term\_statistics": true,  
"field\_statistics":true,  
"filter":{  
"min\_term\_freq":1,  
"max\_doc\_freq": 3  
}  
},  
{  
"\_index": "je\_test",  
"\_type": "je\_tweet",  
"\_id": "1",  
"fields":["contents"],  
"offsets":false,  
"payloads":false,  
"positions":false,  
"term\_statistics": true,  
"field\_statistics":true,  
"filter":{  
"min\_term\_freq":1,  
"max\_doc\_freq": 3  
}  
}  
]  
}

2. 검색 결과 저장할 인덱스 맵핑  
PUT ok\_index  
{  
"mappings": {  
"word": {  
"properties": {  
"termsarray": {  
"type": "nested",  
"properties": {  
"form": {  
"type":"text",  
"fielddata": true  
}  
}  
}  
}  
}  
}  
}

3. 어그리게이션 사용해서 단어별 점수 구하기  
GET ok\_index/\_search  
{  
"aggs" : {  
"termsarray" : {  
"nested" : {  
"path" : "termsarray"  
},  
"aggs" : {  
"word" : {  
"terms" : {  
"field" : "termsarray.form",  
"order" : { "sum\_score" : "desc" }  
},  
"aggs" : {  
"sum\_score" : { "sum" : { "field" : "termsarray.score" }}  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 7, 2017, 7:29pm UTC](https://discuss.elastic.co/t/mtermvectors/74273/2 "2017-03-07T19:29:21Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
