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

Limit token filter

원문 보기 위키 갱신

출처: 문서

본문

Limit 토큰 필터

limit 토큰 필터는 분석 체인을 통과하는 토큰의 개수를 제한하는 데 사용해요.

파라미터

limit 토큰 필터는 다음 파라미터로 설정할 수 있어요.

파라미터 필수/선택 데이터 타입 설명
max_token_count 선택 Integer 생성될 토큰의 최대 개수예요. 기본값은 1이에요.
consume_all_tokens 선택 Boolean (전문가 수준 설정) 결과가 max_token_count를 초과하더라도 토크나이저의 모든 토큰을 사용해요. 이 파라미터가 설정되면 출력에는 여전히 max_token_count에서 지정한 개수의 토큰만 포함되지만, 토크나이저가 생성한 모든 토큰이 처리돼요. 기본값은 false예요.

예시

다음 예시 요청은 my_index라는 이름의 새 인덱스를 생성하고 limit 필터가 설정된 애널라이저를 구성해요:

PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "three_token_limit": {
          "tokenizer": "standard",
          "filter": [ "custom_token_limit" ]
        }
      },
      "filter": {
        "custom_token_limit": {
          "type": "limit",
          "max_token_count": 3
        }
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

다음 요청을 사용해서 애널라이저로 생성된 토큰을 확인해 보세요:

GET /my_index/_analyze
{
  "analyzer": "three_token_limit",
  "text": "OpenSearch is a powerful and flexible search engine."
}

{% include copy-curl.html %}

응답에는 생성된 토큰이 포함돼요:

{
  "tokens": [
    {
      "token": "OpenSearch",
      "start_offset": 0,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "is",
      "start_offset": 11,
      "end_offset": 13,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "a",
      "start_offset": 14,
      "end_offset": 15,
      "type": "<ALPHANUM>",
      "position": 2
    }
  ]
}

더 알아보기 (Learn more)