Тип поля бинарных данных
Тип binary принимает бинарное значение в виде закодированной в Base64 строке. Поле по умолчанию не сохраняется и не индексируется для поиска:
resp = client.indices.create(
index="my-index-000001",
mappings={
"properties": {
"name": {
"type": "text"
},
"blob": {
"type": "binary"
}
}
},
)
print(resp)
resp1 = client.index(
index="my-index-000001",
id="1",
document={
"name": "Some binary blob",
"blob": "U29tZSBiaW5hcnkgYmxvYg=="
},
)
print(resp1) response = client.indices.create(
index: 'my-index-000001',
body: {
mappings: {
properties: {
name: {
type: 'text'
},
blob: {
type: 'binary'
}
}
}
}
)
puts response
response = client.index(
index: 'my-index-000001',
id: 1,
body: {
name: 'Some binary blob',
blob: 'U29tZSBiaW5hcnkgYmxvYg=='
}
)
puts response const response = await client.indices.create({
index: "my-index-000001",
mappings: {
properties: {
name: {
type: "text",
},
blob: {
type: "binary",
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 1,
document: {
name: "Some binary blob",
blob: "U29tZSBiaW5hcnkgYmxvYg==",
},
});
console.log(response1); PUT my-index-000001
{
"mappings": {
"properties": {
"name": {
"type": "text"
},
"blob": {
"type": "binary"
}
}
}
}
PUT my-index-000001/_doc/1
{
"name": "Some binary blob",
"blob": "U29tZSBiaW5hcnkgYmxvYg=="
} | Закодированное в Base64 бинарное значение не должно содержать встроенных символов новой строки |
Параметры для полей binary
Следующие параметры принимаются полями binary:
| Должно ли поле храниться на диске в виде столбцов, чтобы его можно было позже использовать для сортировки, агрегаций или скриптинга? Принимает значения | |
| Должно ли значение поля храниться и извлекаться отдельно от поля |
Синтетическое поле _source
Синтетическое поле _source доступно только для индексов TSDB (индексы, для которых index.mode установлено в значение time_series). Для других индексов синтетическое поле _source находится в техническом предварительном просмотре. Функции в техническом предварительном просмотре могут быть изменены или удалены в будущих выпусках. Elastic будет работать над исправлением любых проблем, но функции в техническом предварительном просмотре не подпадают под SLA поддержки официальных функций GA.
Синтетическое поле может сортировать значения binary в порядке их байтового представления. Например:
response = client.indices.create(
index: 'idx',
body: {
mappings: {
_source: {
mode: 'synthetic'
},
properties: {
binary: {
type: 'binary',
doc_values: true
}
}
}
}
)
puts response
response = client.index(
index: 'idx',
id: 1,
body: {
binary: [
'IAA=',
'EAA='
]
}
)
puts response PUT idx
{
"mappings": {
"_source": { "mode": "synthetic" },
"properties": {
"binary": { "type": "binary", "doc_values": true }
}
}
}
PUT idx/_doc/1
{
"binary": ["IAA=", "EAA="]
} Преобразуется в:
{
"binary": ["EAA=", "IAA="]
}
© 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/binary.html