Truncate token filter
출처: 문서
본문
Truncate 토큰 필터
truncate 토큰 필터는 지정된 길이를 초과하는 토큰을 짧게 줄이는 데 사용해요. 토큰을 최대 문자 수에 맞춰 잘라내기 때문에, 이 한도를 넘는 토큰은 잘려 나가요.
파라미터
truncate 토큰 필터는 다음 파라미터로 설정할 수 있어요.
| 파라미터 | 필수/선택 | 데이터 타입 | 설명 |
|---|---|---|---|
length |
선택 | Integer | 생성되는 토큰의 최대 길이를 지정해요. 기본값은 10이에요. |
예제
다음 예제 요청은 truncate_example이라는 새 인덱스를 만들고, truncate 필터가 적용된 애널라이저를 구성해요:
PUT /truncate_example
{
"settings": {
"analysis": {
"filter": {
"truncate_filter": {
"type": "truncate",
"length": 5
}
},
"analyzer": {
"truncate_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"truncate_filter"
]
}
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
다음 요청을 사용하면 애널라이저가 생성한 토큰을 확인할 수 있어요:
GET /truncate_example/_analyze
{
"analyzer": "truncate_analyzer",
"text": "OpenSearch is powerful and scalable"
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{
"token": "opens",
"start_offset": 0,
"end_offset": 10,
"type": "<ALPHANUM>",
"position": 0
},
{
"token": "is",
"start_offset": 11,
"end_offset": 13,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "power",
"start_offset": 14,
"end_offset": 22,
"type": "<ALPHANUM>",
"position": 2
},
{
"token": "and",
"start_offset": 23,
"end_offset": 26,
"type": "<ALPHANUM>",
"position": 3
},
{
"token": "scala",
"start_offset": 27,
"end_offset": 35,
"type": "<ALPHANUM>",
"position": 4
}
]
}