Токенизатор групп символов
Токенизатор char_group разбивает текст на термины всякий раз, когда встречается символ, который входит в определенный набор. Он в основном полезен в тех случаях, когда требуется простая пользовательская токенизация, а накладные расходы на использование pattern токенизатора неприемлемы.
Настройка
Токенизатор char_group принимает один параметр:
| | Список, содержащий список символов, на которых необходимо разбить строку. Всякий раз, когда встречается символ из этого списка, начинается новый токен. Это принимает как отдельные символы, например, |
| | Максимальная длина токена. Если встречается токен, длина которого превышает это значение, то он разбивается на интервалы |
Пример вывода
resp = client.indices.analyze(
tokenizer={
"type": "char_group",
"tokenize_on_chars": [
"whitespace",
"-",
"\n"
]
},
text="The QUICK brown-fox",
)
print(resp) response = client.indices.analyze(
body: {
tokenizer: {
type: 'char_group',
tokenize_on_chars: [
'whitespace',
'-',
"\n"
]
},
text: 'The QUICK brown-fox'
}
)
puts response const response = await client.indices.analyze({
tokenizer: {
type: "char_group",
tokenize_on_chars: ["whitespace", "-", "\n"],
},
text: "The QUICK brown-fox",
});
console.log(response); POST _analyze
{
"tokenizer": {
"type": "char_group",
"tokenize_on_chars": [
"whitespace",
"-",
"\n"
]
},
"text": "The QUICK brown-fox"
} возвращает
{
"tokens": [
{
"token": "The",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 0
},
{
"token": "QUICK",
"start_offset": 4,
"end_offset": 9,
"type": "word",
"position": 1
},
{
"token": "brown",
"start_offset": 10,
"end_offset": 15,
"type": "word",
"position": 2
},
{
"token": "fox",
"start_offset": 16,
"end_offset": 19,
"type": "word",
"position": 3
}
]
}
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/analysis-chargroup-tokenizer.html