Elastic Search

ElasticSearch Analyzer 정리

miin1635@ 2023. 11. 28. 15:34

analyzer 는 _analyze API 중 하나이며, 분석기 역할을 한다. 

analyzer 에는 세 가지 요소가 들어가있다. 1. 필터 , 2. 토크나이저 3. 캐릭터

 

_analyze {

text: {phrase} 를 analyzer:{my_analyzer}}

로 분석할 수 있다. 다음은 예시이다. 

GET _analyze{
"text": "The quick brown fox jumps over the lazy dog",
"tokenizer": "whitespace",
"filter": [
"lowercase",
 
"stop",
 
"snowball"]
}
또한 특정 인덱스의 필드에 analyzer를 적용시킬 수 있다. 
 
PUT my_index2
 
{
 
"mappings": {
       "properties": {
               "message": {
                       "type": "text",
                       "analyzer": "snowball"
                                  }
                            }
                     }
}

 

  1. my_index2/doc/1에 데이터 삽입 후
PUT my_index2/_doc/1
{
"message": "The quick brown fox jumps over the lazy dog"
}
 
    2.  검색 쿼리로 검색
 
GET my_index2/_search
{
"query": {
                  "match": {
                             "message": "jumping"
                                }
                     }
}
 
3. 결과 
 
 
 
 

출처 : https://esbook.kimjmin.net/06-text-analysis/6.3-analyzer-1/6.3-analyzer

'Elastic Search' 카테고리의 다른 글

[Elasticsearch] TF/IDF, BM25, RRF  (1) 2023.12.11
[ElasticSearch] master노드가 3개 이상 이여야 하는 이유  (1) 2023.12.06
ES - Runtime field  (0) 2023.10.17
Bool query (must 와 should)  (0) 2023.10.06
ES API 정리 (rare한 것 )  (0) 2023.09.21