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

English analyzer

원문 보기 위키 갱신

출처: 문서

본문

영어 애널라이저

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

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

{% include copy-curl.html %}

스템 제외

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

PUT index_with_stem_exclusion_english_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_english_analyzer": {
          "type": "english",
          "stem_exclusion": ["authority", "authorization"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

영어 애널라이저 내부 구조

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

  • 토크나이저: standard

  • 토큰 필터:

    • stemmer (possessive_english)
    • lowercase
    • stop (English)
    • keyword
    • stemmer (English)

커스텀 영어 애널라이저

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

PUT /english-index
{
  "settings": {
    "analysis": {
      "filter": {
        "english_stop": {
          "type": "stop",
          "stopwords": "_english_"
        },
        "english_stemmer": {
          "type": "stemmer",
          "language": "english"
        },
        "english_keywords": {
          "type": "keyword_marker",
          "keywords": []
        },
        "english_possessive_stemmer": {
          "type":       "stemmer",
          "language":   "possessive_english"
        }
      },
      "analyzer": {
        "english_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "english_possessive_stemmer",
            "lowercase",
            "english_stop",
            "english_keywords",
            "english_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "english_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

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

POST /english-index/_analyze
{
  "field": "content",
  "text": "The students study in the USA and work at NASA. Their numbers are 123456."
}

{% include copy-curl.html %}

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

{
  "tokens": [
    {"token": "student","start_offset": 4,"end_offset": 12,"type": "<ALPHANUM>","position": 1},
    {"token": "studi","start_offset": 13,"end_offset": 18,"type": "<ALPHANUM>","position": 2},
    {"token": "usa","start_offset": 26,"end_offset": 29,"type": "<ALPHANUM>","position": 5},
    {"token": "work","start_offset": 34,"end_offset": 38,"type": "<ALPHANUM>","position": 7},
    {"token": "nasa","start_offset": 42,"end_offset": 46,"type": "<ALPHANUM>","position": 9},
    {"token": "number","start_offset": 54,"end_offset": 61,"type": "<ALPHANUM>","position": 11},
    {"token": "123456","start_offset": 66,"end_offset": 72,"type": "<NUM>","position": 13}
  ]
}

더 알아보기 (Learn more)