Tokenizer란?
Tokenizer는 Elasticsearch Analyzer 중 2번째로 동작하는 구성 요소로써 Character Filter에서 처리된 문자열을 잘게 나누어서 토큰을 만드는 역할을 한다.
예를 들어, “elasticsearch is a search engine” 이라는 문장을 standard tokenizer로 분석하게 되면 아래와 같이 나누어지게 된다.
["elasticsearch", "is", "a", "search", "engine"]
JSON
복사
Tokenizer의 종류
1.
Standard : 공백으로 term을 구분하면서 특수 문자를 제거한다. (default)
POST _analyze
{
"tokenizer": "standard",
"text": "I'm learning Elasticsearch"
}
JSON
복사
["I", "m", "learning", "Elasticsearch"]
JSON
복사
2.
whitespace : 공백으로만 term을 구분
POST _analyze
{
"tokenizer": "whitespace",
"text": "I'm learning Elasticsearch"
}
JSON
복사
["I'm", "learning", "Elasticsearch"]
JSON
복사
3.
keyword : 문자열 전체를 한 덩어리로 저장
POST _analyze
{
"tokenizer": "keyword",
"text": "I'm learning Elasticsearch"
}
JSON
복사
["I'm learning Elasticsearch"]
JSON
복사
4.
uax_url_email : URL이나 이메일을 하나의 토큰으로 유지
POST _analyze
{
"tokenizer": "uax_url_email",
"text": "Contact: hello@gmail.com or visit https://example.com/page"
}
JSON
복사
["Contact", "hello@gmail.com", "or", "visit", "https://example.com/page"]
JSON
복사