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

Hungarian analyzer

원문 보기 위키 갱신

출처: 문서

본문

헝가리어 애널라이저

내장된 hungarian 애널라이저는 다음 명령을 사용해 텍스트 필드에 적용할 수 있어요:

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

{% include copy-curl.html %}

스템 제외

다음 명령을 사용하면 이 언어 애널라이저에서 stem_exclusion을 사용할 수 있어요:

PUT index_with_stem_exclusion_hungarian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_hungarian_analyzer": {
          "type": "hungarian",
          "stem_exclusion": ["hatalom", "jóváhagyás"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

헝가리어 애널라이저 내부 구조

hungarian 애널라이저는 다음 구성 요소로 만들어져 있어요:

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (Hungarian)
    • keyword
    • stemmer (Hungarian)

커스텀 헝가리어 애널라이저

다음 명령을 사용해 커스텀 헝가리어 애널라이저를 만들 수 있어요:

PUT /hungarian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "hungarian_stop": {
          "type": "stop",
          "stopwords": "_hungarian_"
        },
        "hungarian_stemmer": {
          "type": "stemmer",
          "language": "hungarian"
        },
        "hungarian_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "hungarian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "hungarian_stop",
            "hungarian_keywords",
            "hungarian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "hungarian_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

애널라이저가 생성한 토큰을 살펴보려면 다음 요청을 사용하세요:

POST /hungarian-index/_analyze
{
  "field": "content",
  "text": "A diákok a magyar egyetemeken tanulnak. A számaik 123456."
}

{% include copy-curl.html %}

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

{
  "tokens": [
    {
      "token": "diák",
      "start_offset": 2,
      "end_offset": 8,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "magyar",
      "start_offset": 11,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "egyetem",
      "start_offset": 18,
      "end_offset": 29,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "tanul",
      "start_offset": 30,
      "end_offset": 38,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "szám",
      "start_offset": 42,
      "end_offset": 49,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "123456",
      "start_offset": 50,
      "end_offset": 56,
      "type": "<NUM>",
      "position": 8
    }
  ]
}

더 알아보기 (Learn more)