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

Danish analyzer

원문 보기 위키 갱신

출처: 문서

본문

덴마크어 분석기

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

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

{% include copy-curl.html %}

어간 제외

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

PUT index_with_stem_exclusion_danish_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_danish_analyzer": {
          "type": "danish",
          "stem_exclusion": ["autoritet", "godkendelse"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

덴마크어 분석기 내부 구조

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

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (Danish)
    • keyword
    • stemmer (Danish)

커스텀 덴마크어 분석기

다음 명령을 사용해 커스텀 덴마크어 분석기를 만들 수 있어요:

PUT /danish-index
{
  "settings": {
    "analysis": {
      "filter": {
        "danish_stop": {
          "type": "stop",
          "stopwords": "_danish_"
        },
        "danish_stemmer": {
          "type": "stemmer",
          "language": "danish"
        },
        "danish_keywords": {
          "type":       "keyword_marker",
          "keywords":   [] 
        }
      },
      "analyzer": {
        "danish_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "danish_stop",
            "danish_keywords",
            "danish_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "danish_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

다음 요청을 사용하면 분석기가 생성한 토큰을 살펴볼 수 있어요:

POST /danish-index/_analyze
{
  "field": "content",
  "text": "Studerende studerer på de danske universiteter. Deres numre er 123456."
}

{% include copy-curl.html %}

응답에는 생성된 토큰이 포함되어 있어요:

{
  "tokens": [
    {
      "token": "stud",
      "start_offset": 0,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "stud",
      "start_offset": 11,
      "end_offset": 19,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "dansk",
      "start_offset": 26,
      "end_offset": 32,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "universitet",
      "start_offset": 33,
      "end_offset": 46,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "numr",
      "start_offset": 54,
      "end_offset": 59,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "123456",
      "start_offset": 63,
      "end_offset": 69,
      "type": "<NUM>",
      "position": 9
    }
  ]
}

더 알아보기 (Learn more)