二进制字段类型
编辑二进制字段类型
编辑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==" }
binary
字段的参数
编辑binary
字段接受以下参数:
是否应以列式存储方式将该字段存储在磁盘上,以便稍后用于排序、聚合或脚本?接受 |
|
是否应存储该字段值,并可从 |
合成 _source
编辑合成 _source
仅对 TSDB 索引(index.mode
设置为 time_series
的索引)正式可用。 对于其他索引,合成 _source
处于技术预览阶段。技术预览版中的功能可能会在未来版本中更改或删除。Elastic 将努力解决任何问题,但技术预览版中的功能不受官方 GA 功能的支持 SLA 约束。
合成源可能会按照字节表示的顺序对 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="] }