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

Portuguese analyzer

원문 보기 위키 갱신

출처: 문서

본문

포르투갈어 분석기

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

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

{% include copy-curl.html %}

스테밍 제외

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

PUT index_with_stem_exclusion_portuguese_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "stem_exclusion_portuguese_analyzer": {
          "type": "portuguese",
          "stem_exclusion": ["autoridade", "aprovação"]
        }
      }
    }
  }
}

{% include copy-curl.html %}

포르투갈어 분석기 내부 구조

portuguese 분석기는 다음 구성 요소들로 만들어져 있어요:

  • 토크나이저: standard

  • 토큰 필터:

    • lowercase
    • stop (포르투갈어)
    • keyword
    • stemmer (포르투갈어)

커스텀 포르투갈어 분석기

다음 명령어를 사용해서 커스텀 포르투갈어 분석기를 만들 수 있어요:

PUT /portuguese-index
{
  "settings": {
    "analysis": {
      "filter": {
        "portuguese_stop": {
          "type": "stop",
          "stopwords": "_portuguese_"
        },
        "portuguese_stemmer": {
          "type": "stemmer",
          "language": "light_portuguese"
        },
        "portuguese_keywords": {
          "type": "keyword_marker",
          "keywords": []
        }
      },
      "analyzer": {
        "portuguese_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "portuguese_stop",
            "portuguese_keywords",
            "portuguese_stemmer"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "portuguese_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

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

POST /portuguese-index/_analyze
{
  "field": "content",
  "text": "Os estudantes estudam nas universidades brasileiras. Seus números são 123456."
}

{% include copy-curl.html %}

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

{
  "tokens": [
    {
      "token": "estudant",
      "start_offset": 3,
      "end_offset": 13,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "estudam",
      "start_offset": 14,
      "end_offset": 21,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "universidad",
      "start_offset": 26,
      "end_offset": 39,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "brasileir",
      "start_offset": 40,
      "end_offset": 51,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "numer",
      "start_offset": 58,
      "end_offset": 65,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "123456",
      "start_offset": 70,
      "end_offset": 76,
      "type": "<NUM>",
      "position": 9
    }
  ]
}

더 알아보기 (Learn more)