# Analyzer 적용했을 때, term query 관련 질문드립니다

**URL:** <https://discuss.elastic.co/t/analyzer-term-query/86380>\
**Category:** 한국어 질문 및 토론\
**Created:** [May 19, 2017, 8:41am UTC](https://discuss.elastic.co/t/analyzer-term-query/86380 "2017-05-19T08:41:44Z")\
**Posts on this page:** 3\
**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:** [May 19, 2017, 8:41am UTC](https://discuss.elastic.co/t/analyzer-term-query/86380/1 "2017-05-19T08:41:45Z")

</div>

안녕하세요. 현재 엘라스틱서치에 은전한닢 플러그인을 적용해서 사용하려고 테스트해보고 있습니다.  
엘라스틱서치5.1.1 버전에 한글 형태소 분석기 seunjeon을 설치했고, template 구조는 아래와 같습니다.

PUT \_template/news\_template  
{  
"template": "news\*",  
"settings": {  
"number\_of\_shards": 5,  
"number\_of\_replicas": 1,  
"index":{  
"analysis":{  
"analyzer":{  
"eunjeon":{  
"type":"custom",  
"tokenizer":"seunjeon\_default\_tokenizer",  
"filter": ["lowercase","synonym","stopwords"]  
}  
},  
"tokenizer": {  
"seunjeon\_default\_tokenizer": {  
"type": "seunjeon\_tokenizer",  
"index\_eojeol": false,  
"user\_dict\_path":"user\_dic.txt",  
"index\_poses": ["N"],  
"decompound": false  
}  
},  
"filter": {  
"synonym": {  
"type": "synonym",  
"synonyms\_path": "synonyms.txt"  
},  
"stopwords":{  
"type": "stop",  
"stopwords\_path": "stopwords.txt"  
}  
}  
}  
}  
},  
"mappings": {  
"_default_": {  
"\_source": {  
"enabled": true  
},  
"\_all": {  
"enabled": false  
},  
"properties": {  
"title": {  
"type": "text",  
"analyzer": "eunjeon",  
"search\_analyzer": "eunjeon"  
},  
"contents": {  
"type": "text",  
"analyzer": "eunjeon",  
"search\_analyzer": "eunjeon"  
},  
"crawl\_datetime":{  
"type":"date",  
"format": "yyyy-MM-dd HH:mm:ss"  
},  
"url":{  
"type":"text"  
},  
"@timestamp":{  
"type":"date",  
"format":"yyyy-MM-dd'T'HH:mm:ss.SSSZ"  
},  
"publisher":{  
"type":"text",  
"fields": {  
"keyword": {  
"type": "keyword"  
}  
}  
}  
}  
}  
}  
}

이 상태에서 데이터를 넣고 term query를 날리면 검색결과가 하나도 안나오는데요.  
예를 들어 제가 seunjeon에 삼성전자를 NNP로 등록해놓은 상태에서 term query로 삼성전자를 찾으면 total이 0건이 나옵니다.  
GET news-\*/\_search  
{  
"query":{  
"term":{  
"contents":"삼성전자"  
}  
}  
}

제가 공부하기로는 analyzer를 설정하면 엔드포인트를 \_analyzer로 쿼리를 날렸을 때 역색인을 해서 결과를 보여주는거고,  
search\_analyzer는 엔드포인트를 \_search로 날렸을 때 analyzer를 적용해서 역색인 한 후 결과를 반환해주는 걸로 알고있습니다.  
그래서 term query를 날렸을 때는 제가 설정한 analyzer가 적용안되고, 문서에 '삼성전자'라는 텍스트가 있으면 무조건 검색에 걸리는 걸로 알고있는데요. 아닌가요?  
match query로 삼성전자를 검색하면 결과가 잘 나옵니다.  
설정이 잘못되었다면 어디가 잘못되었는지, 아니면 맞는 결과라면 왜 맞는지 설명해주실 수 있나요???

추가로 현재 5.4.0에서는 은전한닢으로 테스트 중인데, 또 여기서는 똑같이 analyzer, search\_analyzer를 설정해도 term query로 삼성전자를 검색했을 때 결과가 잘 나옵니다.  
analyzer, search\_analyzer를 적용했을 때 어떤게 맞는건가요?

---

<div class="post-metadata">

**Author:** ![JongminKim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jongminkim/32/15223_2.png) [@JongminKim](https://discuss.elastic.co/u/JongminKim)\
**Post date:** [May 29, 2017, 1:01am UTC](https://discuss.elastic.co/t/analyzer-term-query/86380/2 "2017-05-29T01:01:29Z")

</div>

질문이 명확하게 이해가 되질 않는데요  
우선 analyzer 는 데이터 색인 시 색인하는 분석기를 지정하는 것이고  
search\_analyzer 는 검색 시 검색문을 분석하는 분석기를 지정하는 것입니다.

예를 들어 search\_analyzer 를 ngram 으로 하고 "삼성전자" 를 검색하면  
`삼`, `삼성`, `삼성전`, `삼성전자`  
4개를 검색한 것으로 됩니다.

---

<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:** [June 26, 2017, 1:01am UTC](https://discuss.elastic.co/t/analyzer-term-query/86380/3 "2017-06-26T01:01:29Z")

</div>

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