ignore_above
Строки, длина которых превышает значение параметра ignore_above, не будут индексироваться или храниться. Для массивов строк параметр ignore_above будет применяться к каждому элементу массива отдельно, и строковые элементы, длина которых превышает ignore_above, не будут индексироваться или храниться.
Все строки/элементы массивов по-прежнему будут присутствовать в поле _source, если оно включено, что является значением по умолчанию в Elasticsearch.
resp = client.indices.create(
index="my-index-000001",
mappings={
"properties": {
"message": {
"type": "keyword",
"ignore_above": 20
}
}
},
)
print(resp)
resp1 = client.index(
index="my-index-000001",
id="1",
document={
"message": "Syntax error"
},
)
print(resp1)
resp2 = client.index(
index="my-index-000001",
id="2",
document={
"message": "Syntax error with some long stacktrace"
},
)
print(resp2)
resp3 = client.search(
index="my-index-000001",
aggs={
"messages": {
"terms": {
"field": "message"
}
}
},
)
print(resp3) response = client.indices.create(
index: 'my-index-000001',
body: {
mappings: {
properties: {
message: {
type: 'keyword',
ignore_above: 20
}
}
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 1,
body: {
message: 'Syntax error'
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 2,
body: {
message: 'Syntax error with some long stacktrace'
}
)
puts response
response = client.search(
index: 'my-index-000001',
body: {
aggregations: {
messages: {
terms: {
field: 'message'
}
}
}
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
mappings: {
properties: {
message: {
type: "keyword",
ignore_above: 20,
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 1,
document: {
message: "Syntax error",
},
});
console.log(response1);
const response2 = await client.index({
index: "my-index-000001",
id: 2,
document: {
message: "Syntax error with some long stacktrace",
},
});
console.log(response2);
const response3 = await client.search({
index: "my-index-000001",
aggs: {
messages: {
terms: {
field: "message",
},
},
},
});
console.log(response3); PUT my-index-000001
{
"mappings": {
"properties": {
"message": {
"type": "keyword",
"ignore_above": 20
}
}
}
}
PUT my-index-000001/_doc/1
{
"message": "Syntax error"
}
PUT my-index-000001/_doc/2
{
"message": "Syntax error with some long stacktrace"
}
GET my-index-000001/_search
{
"aggs": {
"messages": {
"terms": {
"field": "message"
}
}
}
} | Это поле проигнорирует любую строку, длина которой превышает 20 символов. | |
| Этот документ успешно индексирован. | |
| Этот документ будет проиндексирован, но без индексации поля | |
| Поиск возвращает оба документа, но только первый присутствует в агрегации по терминам. |
Значение параметра ignore_above можно обновить для существующих полей, используя API обновления мапирования.
Этот параметр также полезен для защиты от ограничения длины термина в байтах Lucene, равного 32766.
Значение для ignore_above — это количество символов, но Lucene считает байты. Если вы используете текст UTF-8 с множеством символов, отличных от ASCII, вам может потребоваться установить ограничение на 32766 / 4 = 8191, так как символы UTF-8 могут занимать не более 4 байтов.
© 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/ignore-above.html