본문 바로가기
WIKI 기술 지식 베이스

Finnish analyzer

원문 보기 위키 갱신

출처: 문서

본문

핀란드어 분석기

내장된 finnish 분석기는 다음 명령어를 사용해서 텍스트 필드에 적용할 수 있어요:

PUT /finnish-index
{
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "finnish"
      }
    }
  }
}

{% include copy-curl.html %}

어간 제외

다음 명령어를 사용하면 이 언어 분석기에서 stem_exclusion을 사용할 수 있어요:

PUT index_with_stem_exclusion_finnish_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_finnish_analyzer": {
          "type": "finnish",
          "stem_exclusion": ["valta", "hyväksyntä"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

핀란드어 분석기 내부 구조

finnish 분석기는 다음 구성 요소들로 만들어져 있어요:

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (Finnish)
    • keyword
    • stemmer (Finnish)

커스텀 핀란드어 분석기

다음 명령어를 사용해서 커스텀 핀란드어 분석기를 만들 수 있어요:

PUT /finnish-index
{
  "settings": {
    "analysis": {
      "filter": {
        "finnish_stop": {
          "type": "stop",
          "stopwords": "_finnish_"
        },
        "finnish_stemmer": {
          "type": "stemmer",
          "language": "finnish"
        },
        "finnish_keywords": {
          "type": "keyword_marker",
          "keywords": ["Helsinki", "Suomi"]
        }
      },
      "analyzer": {
        "finnish_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "finnish_stop",
            "finnish_keywords",
            "finnish_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "finnish_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

다음 요청을 사용해서 분석기가 생성한 토큰을 살펴보세요:

POST /finnish-index/_analyze
{
  "field": "content",
  "text": "Opiskelijat opiskelevat Helsingissä ja Suomen yliopistoissa. Heidän numeronsa ovat 123456."
}

{% include copy-curl.html %}

응답에는 생성된 토큰이 담겨 있어요:

{
  "tokens": [
    {"token": "opiskelij","start_offset": 0,"end_offset": 11,"type": "<ALPHANUM>","position": 0},
    {"token": "opiskelev","start_offset": 12,"end_offset": 23,"type": "<ALPHANUM>","position": 1},
    {"token": "helsing","start_offset": 24,"end_offset": 35,"type": "<ALPHANUM>","position": 2},
    {"token": "suome","start_offset": 39,"end_offset": 45,"type": "<ALPHANUM>","position": 4},
    {"token": "yliopisto","start_offset": 46,"end_offset": 59,"type": "<ALPHANUM>","position": 5},
    {"token": "numero","start_offset": 68,"end_offset": 77,"type": "<ALPHANUM>","position": 7},
    {"token": "123456","start_offset": 83,"end_offset": 89,"type": "<NUM>","position": 9}
  ]
}

더 알아보기 (Learn more)