Length token filter
출처: 문서
본문
Length 토큰 필터
length 토큰 필터는 토큰 스트림에서 지정된 길이 조건(최솟값과 최댓값)을 충족하지 않는 토큰을 제거하는 데 사용돼요.
파라미터
length 토큰 필터는 다음 파라미터로 설정할 수 있어요.
| 파라미터 | 필수/선택 | 데이터 타입 | 설명 |
|---|---|---|---|
min |
선택 | Integer | 토큰의 최소 길이예요. 기본값은 0이에요. |
max |
선택 | Integer | 토큰의 최대 길이예요. 기본값은 Integer.MAX_VALUE(2147483647)예요. |
예제
다음 예제 요청은 my_index라는 이름의 새 인덱스를 생성하고 length 필터가 설정된 애널라이저를 구성해요:
PUT my_index
{
"settings": {
"analysis": {
"analyzer": {
"only_keep_4_to_10_characters": {
"tokenizer": "whitespace",
"filter": [ "length_4_to_10" ]
}
},
"filter": {
"length_4_to_10": {
"type": "length",
"min": 4,
"max": 10
}
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
다음 요청을 사용해서 애널라이저가 생성한 토큰을 확인해 보세요:
GET /my_index/_analyze
{
"analyzer": "only_keep_4_to_10_characters",
"text": "OpenSearch is a great tool!"
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{
"token": "OpenSearch",
"start_offset": 0,
"end_offset": 10,
"type": "word",
"position": 0
},
{
"token": "great",
"start_offset": 16,
"end_offset": 21,
"type": "word",
"position": 3
},
{
"token": "tool!",
"start_offset": 22,
"end_offset": 27,
"type": "word",
"position": 4
}
]
}