White space tokenizer
출처: 문서
본문
White space 토크나이저
whitespace 토크나이저는 공백, 탭, 줄바꿈 같은 공백 문자를 기준으로 텍스트를 분리해요. 공백으로 구분된 각 단어를 하나의 토큰으로 취급하며, 소문자 변환이나 문장부호 제거 같은 추가적인 분석이나 정규화는 수행하지 않아요.
사용 예시
다음 예시 요청은 my_index라는 이름의 새 인덱스를 만들고 whitespace 토크나이저를 사용하는 애널라이저를 설정해요:
PUT /my_index
{
"settings": {
"analysis": {
"tokenizer": {
"whitespace_tokenizer": {
"type": "whitespace"
}
},
"analyzer": {
"my_whitespace_analyzer": {
"type": "custom",
"tokenizer": "whitespace_tokenizer"
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "my_whitespace_analyzer"
}
}
}
}
{% include copy-curl.html %}
생성된 토큰
다음 요청을 사용하면 애널라이저가 생성한 토큰을 확인할 수 있어요:
POST /my_index/_analyze
{
"analyzer": "my_whitespace_analyzer",
"text": "OpenSearch is fast! Really fast."
}
{% include copy-curl.html %}
응답에는 생성된 토큰이 담겨 있어요:
{
"tokens": [
{
"token": "OpenSearch",
"start_offset": 0,
"end_offset": 10,
"type": "word",
"position": 0
},
{
"token": "is",
"start_offset": 11,
"end_offset": 13,
"type": "word",
"position": 1
},
{
"token": "fast!",
"start_offset": 14,
"end_offset": 19,
"type": "word",
"position": 2
},
{
"token": "Really",
"start_offset": 20,
"end_offset": 26,
"type": "word",
"position": 3
},
{
"token": "fast.",
"start_offset": 27,
"end_offset": 32,
"type": "word",
"position": 4
}
]
}
파라미터
whitespace 토크나이저는 다음 파라미터로 설정할 수 있어요.
| 파라미터 | 필수/선택 | 데이터 타입 | 설명 |
|---|---|---|---|
max_token_length |
선택 | Integer | 생성되는 토큰의 최대 길이를 설정해요. 이 길이를 초과하면 토큰이 max_token_length에 설정된 길이를 기준으로 여러 토큰으로 분리돼요. 기본값은 255예요. |