Фильтр токенов KStem
Предоставляет стемминг на основе KStem для английского языка. Фильтр kstem сочетает алгоритмический стемминг с встроенным алгоритмом и словарём.
Фильтр kstem имеет тенденцию к менее агрессивному стеммингу, чем другие фильтры стемминга для английского языка, такие как фильтр porter_stem.
Фильтр kstem эквивалентен варианту stemmer фильтра с light_english.
Этот фильтр использует KStemFilter из Lucene.
Пример
Следующий запрос к API analyze использует фильтр kstem для стемминга the foxes
jumping quickly в the fox jump quick:
resp = client.indices.analyze(
tokenizer="standard",
filter=[
"kstem"
],
text="the foxes jumping quickly",
)
print(resp) response = client.indices.analyze(
body: {
tokenizer: 'standard',
filter: [
'kstem'
],
text: 'the foxes jumping quickly'
}
)
puts response const response = await client.indices.analyze({
tokenizer: "standard",
filter: ["kstem"],
text: "the foxes jumping quickly",
});
console.log(response); GET /_analyze
{
"tokenizer": "standard",
"filter": [ "kstem" ],
"text": "the foxes jumping quickly"
} Фильтр производит следующие токены:
[ the, fox, jump, quick ]
Добавление в анализатор
Следующий запрос к API создания индекса использует фильтр kstem для настройки нового пользовательского анализатора.
Для корректной работы фильтр kstem требует токенов в нижнем регистре. Чтобы убедиться, что токены приведены к нижнему регистру, добавьте фильтр lowercase перед фильтром kstem в конфигурацию анализатора.
resp = client.indices.create(
index="my-index-000001",
settings={
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "whitespace",
"filter": [
"lowercase",
"kstem"
]
}
}
}
},
)
print(resp) response = client.indices.create(
index: 'my-index-000001',
body: {
settings: {
analysis: {
analyzer: {
my_analyzer: {
tokenizer: 'whitespace',
filter: [
'lowercase',
'kstem'
]
}
}
}
}
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
settings: {
analysis: {
analyzer: {
my_analyzer: {
tokenizer: "whitespace",
filter: ["lowercase", "kstem"],
},
},
},
},
});
console.log(response); PUT /my-index-000001
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "whitespace",
"filter": [
"lowercase",
"kstem"
]
}
}
}
}
}
© 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-kstem-tokenfilter.html