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

Czech analyzer

원문 보기 위키 갱신

출처: 문서

본문

체코어 분석기

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

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

{% include copy-curl.html %}

어간 제외

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

PUT index_with_stem_exclusion_czech_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_czech_analyzer": {
          "type": "czech",
          "stem_exclusion": ["autorita", "schválení"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

체코어 분석기 내부 구조

czech 분석기는 다음 구성 요소로 이루어져 있어요:

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (체코어)
    • keyword
    • stemmer (체코어)

커스텀 체코어 분석기

다음 명령어를 사용해 커스텀 체코어 분석기를 만들 수 있어요:

PUT /czech-index
{
  "settings": {
    "analysis": {
      "filter": {
        "czech_stop": {
          "type": "stop",
          "stopwords": "_czech_"
        },
        "czech_stemmer": {
          "type": "stemmer",
          "language": "czech"
        },
        "czech_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "czech_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "czech_stop",
            "czech_keywords",
            "czech_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "czech_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

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

POST /czech-index/_analyze
{
  "field": "content",
  "text": "Studenti studují na českých univerzitách. Jejich čísla jsou 123456."
}

{% include copy-curl.html %}

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

{
  "tokens": [
    {
      "token": "student",
      "start_offset": 0,
      "end_offset": 8,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "studuj",
      "start_offset": 9,
      "end_offset": 16,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "česk",
      "start_offset": 20,
      "end_offset": 27,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "univerzit",
      "start_offset": 28,
      "end_offset": 40,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "čísl",
      "start_offset": 49,
      "end_offset": 54,
      "type": "<ALPHANUM>",
      "position": 6
    },
    {
      "token": "123456",
      "start_offset": 60,
      "end_offset": 66,
      "type": "<NUM>",
      "position": 8
    }
  ]
}

더 알아보기 (Learn more)