Анализатор отпечатков пальцев
Анализатор fingerprint реализует алгоритм отпечатков пальцев, используемый проектом OpenRefine для кластеризации.
Текст на входе преобразуется в нижний регистр, нормализуется для удаления расширенных символов, сортируется, дубликаты удаляются, а затем все это конкатенируется в один токен. Если настроено использование стоп-слов, стоп-слова также будут удалены.
Пример вывода
resp = client.indices.analyze(
analyzer="fingerprint",
text="Yes yes, Gödel said this sentence is consistent and.",
)
print(resp) response = client.indices.analyze(
body: {
analyzer: 'fingerprint',
text: 'Yes yes, Gödel said this sentence is consistent and.'
}
)
puts response const response = await client.indices.analyze({
analyzer: "fingerprint",
text: "Yes yes, Gödel said this sentence is consistent and.",
});
console.log(response); POST _analyze
{
"analyzer": "fingerprint",
"text": "Yes yes, Gödel said this sentence is consistent and."
} Вышеприведённое предложение даст следующий единый термин:
[ and consistent godel is said sentence this yes ]
Настройка
Анализатор fingerprint принимает следующие параметры:
| | Символ для конкатенации терминов. По умолчанию пробел. |
| | Максимальный размер токена для вывода. По умолчанию |
| | Список предопределённых стоп-слов, например, |
| | Путь к файлу, содержащему стоп-слова. |
См. Фильтр стоп-слов для получения дополнительной информации о настройке стоп-слов.
Пример конфигурации
В этом примере мы настраиваем анализатор fingerprint для использования предопределённого списка английских стоп-слов:
resp = client.indices.create(
index="my-index-000001",
settings={
"analysis": {
"analyzer": {
"my_fingerprint_analyzer": {
"type": "fingerprint",
"stopwords": "_english_"
}
}
}
},
)
print(resp)
resp1 = client.indices.analyze(
index="my-index-000001",
analyzer="my_fingerprint_analyzer",
text="Yes yes, Gödel said this sentence is consistent and.",
)
print(resp1) response = client.indices.create(
index: 'my-index-000001',
body: {
settings: {
analysis: {
analyzer: {
my_fingerprint_analyzer: {
type: 'fingerprint',
stopwords: '_english_'
}
}
}
}
}
)
puts response
response = client.indices.analyze(
index: 'my-index-000001',
body: {
analyzer: 'my_fingerprint_analyzer',
text: 'Yes yes, Gödel said this sentence is consistent and.'
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
settings: {
analysis: {
analyzer: {
my_fingerprint_analyzer: {
type: "fingerprint",
stopwords: "_english_",
},
},
},
},
});
console.log(response);
const response1 = await client.indices.analyze({
index: "my-index-000001",
analyzer: "my_fingerprint_analyzer",
text: "Yes yes, Gödel said this sentence is consistent and.",
});
console.log(response1); PUT my-index-000001
{
"settings": {
"analysis": {
"analyzer": {
"my_fingerprint_analyzer": {
"type": "fingerprint",
"stopwords": "_english_"
}
}
}
}
}
POST my-index-000001/_analyze
{
"analyzer": "my_fingerprint_analyzer",
"text": "Yes yes, Gödel said this sentence is consistent and."
} Этот пример генерирует следующий термин:
[ consistent godel said sentence yes ]
Определение
Токенизатор fingerprint состоит из:
- Токенизатор
- Фильтры токенов (в порядке)
-
- Фильтр преобразования в нижний регистр
- ASCII-свертка
- Фильтр стоп-слов (выключен по умолчанию)
- Отпечаток пальца
Если вам нужно настроить анализатор fingerprint за пределами параметров конфигурации, необходимо воссоздать его как анализатор custom и изменить его, обычно добавив фильтры токенов. Это позволит воссоздать встроенный анализатор fingerprint, и вы сможете использовать его как отправную точку для дальнейшей настройки:
resp = client.indices.create(
index="fingerprint_example",
settings={
"analysis": {
"analyzer": {
"rebuilt_fingerprint": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding",
"fingerprint"
]
}
}
}
},
)
print(resp) response = client.indices.create(
index: 'fingerprint_example',
body: {
settings: {
analysis: {
analyzer: {
rebuilt_fingerprint: {
tokenizer: 'standard',
filter: [
'lowercase',
'asciifolding',
'fingerprint'
]
}
}
}
}
}
)
puts response const response = await client.indices.create({
index: "fingerprint_example",
settings: {
analysis: {
analyzer: {
rebuilt_fingerprint: {
tokenizer: "standard",
filter: ["lowercase", "asciifolding", "fingerprint"],
},
},
},
},
});
console.log(response); PUT /fingerprint_example
{
"settings": {
"analysis": {
"analyzer": {
"rebuilt_fingerprint": {
"tokenizer": "standard",
"filter": [
"lowercase",
"asciifolding",
"fingerprint"
]
}
}
}
}
}
© 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-fingerprint-analyzer.html