Synonym Token Filter

Analyzer의 Filter에 사용가능한 필터로, 동의어를 처리할 수 있는 필터

(동이어나 불용어, 사용자 사전과 관련된 부분은 나중에 더 Deep하게 보고, 일단 해당 필터에 대해서만 서술함)

 

Parameters

synonyms : 동의어로 등록(사용)할 단어

synonmyms_path : 파일로 관리할 경우 Elasticearch server의 config 폴더 아래에 생성/지정

 

 

1. 분석기 정의

PUT /test_index_for_synonym
{
  "settings": {
    "analysis": {
      "analyzer": {
        "synonym_analyzer": {
          "tokenizer": "whitespace",
          "filter": [
            "synonym_filter"
          ]
        }
      },
      "filter": {
        "synonym_filter": {
          "type": "synonym",
          "synonyms" : [
            "Harry => 해리"
          ]
        }
      }
    }
  }
}

 

2. 분석 Start

POST test_index_for_synonym/_analyze
{
  "analyzer": "synonym_analyzer",
  "text": "Harry Potter and the Chamber of Secrets"
}

 

3. 분석 결과

{
  "tokens" : [
    {
      "token" : "해리",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "SYNONYM",
      "position" : 0
    },
    {
      "token" : "Potter",
      "start_offset" : 6,
      "end_offset" : 12,
      "type" : "word",
      "position" : 1
    },
    {
      "token" : "and",
      "start_offset" : 13,
      "end_offset" : 16,
      "type" : "word",
      "position" : 2
    },
    {
      "token" : "the",
      "start_offset" : 17,
      "end_offset" : 20,
      "type" : "word",
      "position" : 3
    },
    {
      "token" : "Chamber",
      "start_offset" : 21,
      "end_offset" : 28,
      "type" : "word",
      "position" : 4
    },
    {
      "token" : "of",
      "start_offset" : 29,
      "end_offset" : 31,
      "type" : "word",
      "position" : 5
    },
    {
      "token" : "Secrets",
      "start_offset" : 32,
      "end_offset" : 39,
      "type" : "word",
      "position" : 6
    }
  ]
}

 

 

 

 

 

'개발 > Elasticsearch' 카테고리의 다른 글

Local에 docker-compose로 ELK 구성 (+ nori)  (0) 2020.07.03
reindex (index, template migrations)  (0) 2020.07.03
Analyzer 이해하기  (0) 2020.05.20
static index vs dynamic index  (0) 2020.05.20
Mapping Parameters  (0) 2020.05.18

+ Recent posts