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

Norwegian analyzer

원문 보기 위키 갱신

출처: 문서

본문

노르웨이어 애널라이저

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

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

{% include copy-curl.html %}

스테밍 제외

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

PUT index_with_stem_exclusion_norwegian_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_norwegian_analyzer": {
          "type": "norwegian",
          "stem_exclusion": ["autoritet", "godkjenning"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

노르웨이어 애널라이저 내부 구조

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

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (Norwegian)
    • keyword
    • stemmer (Norwegian)

커스텀 노르웨이어 애널라이저

다음 명령어를 사용해서 커스텀 노르웨이어 애널라이저를 만들 수 있어요:

PUT /norwegian-index
{
  "settings": {
    "analysis": {
      "filter": {
        "norwegian_stop": {
          "type": "stop",
          "stopwords": "_norwegian_"
        },
        "norwegian_stemmer": {
          "type": "stemmer",
          "language": "norwegian"
        },
        "norwegian_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "norwegian_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "norwegian_stop",
            "norwegian_keywords",
            "norwegian_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "norwegian_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

애널라이저를 사용해 생성된 토큰을 살펴보려면 다음 요청을 사용해 보세요:

POST /norwegian-index/_analyze
{
  "field": "content",
  "text": "Studentene studerer ved norske universiteter. Deres nummer er 123456."
}

{% include copy-curl.html %}

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

{
  "tokens": [
    {"token": "student","start_offset": 0,"end_offset": 10,"type": "<ALPHANUM>","position": 0},
    {"token": "studer","start_offset": 11,"end_offset": 19,"type": "<ALPHANUM>","position": 1},
    {"token": "norsk","start_offset": 24,"end_offset": 30,"type": "<ALPHANUM>","position": 3},
    {"token": "universitet","start_offset": 31,"end_offset": 44,"type": "<ALPHANUM>","position": 4},
    {"token": "numm","start_offset": 52,"end_offset": 58,"type": "<ALPHANUM>","position": 6},
    {"token": "123456","start_offset": 62,"end_offset": 68,"type": "<NUM>","position": 8}
  ]
}

더 알아보기 (Learn more)