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