Анализатор Keyword
Анализатор keyword — это «пустой» анализатор, который возвращает всю входную строку как один токен.
Пример вывода
resp = client.indices.analyze(
analyzer="keyword",
text="The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.",
)
print(resp) response = client.indices.analyze(
body: {
analyzer: 'keyword',
text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
}
)
puts response const response = await client.indices.analyze({
analyzer: "keyword",
text: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone.",
});
console.log(response); POST _analyze
{
"analyzer": "keyword",
"text": "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."
} Предложение выше даст следующий единственный термин:
[ The 2 QUICK Brown-Foxes jumped over the lazy dog's bone. ]
Настройка
Анализатор keyword не настраивается.
Определение
Анализатор keyword состоит из:
- Токенизатор
Если вам нужно настроить анализатор keyword, то необходимо создать его как анализатор custom и внести изменения, обычно добавив фильтры токенов. Обычно предпочтительнее использовать тип Keyword, когда вам нужны строки, которые не разделяются на токены, но в случае необходимости вы можете воссоздать встроенный анализатор keyword и использовать его в качестве отправной точки для дальнейшей настройки:
resp = client.indices.create(
index="keyword_example",
settings={
"analysis": {
"analyzer": {
"rebuilt_keyword": {
"tokenizer": "keyword",
"filter": []
}
}
}
},
)
print(resp) response = client.indices.create(
index: 'keyword_example',
body: {
settings: {
analysis: {
analyzer: {
rebuilt_keyword: {
tokenizer: 'keyword',
filter: []
}
}
}
}
}
)
puts response const response = await client.indices.create({
index: "keyword_example",
settings: {
analysis: {
analyzer: {
rebuilt_keyword: {
tokenizer: "keyword",
filter: [],
},
},
},
},
});
console.log(response); PUT /keyword_example
{
"settings": {
"analysis": {
"analyzer": {
"rebuilt_keyword": {
"tokenizer": "keyword",
"filter": [
]
}
}
}
}
} | Здесь вы добавите любые фильтры токенов. |
© 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-keyword-analyzer.html