index_prefixes
编辑index_prefixes
编辑index_prefixes
参数允许索引词的前缀以加速前缀搜索。它接受以下可选设置:
|
要索引的最小前缀长度。必须大于 0,默认为 2。该值是包含的。 |
|
要索引的最大前缀长度。必须小于 20,默认为 5。该值是包含的。 |
此示例使用默认的前缀长度设置创建一个文本字段
resp = client.indices.create( index="my-index-000001", mappings={ "properties": { "body_text": { "type": "text", "index_prefixes": {} } } }, ) print(resp)
response = client.indices.create( index: 'my-index-000001', body: { mappings: { properties: { body_text: { type: 'text', index_prefixes: {} } } } } ) puts response
const response = await client.indices.create({ index: "my-index-000001", mappings: { properties: { body_text: { type: "text", index_prefixes: {}, }, }, }, }); console.log(response);
PUT my-index-000001 { "mappings": { "properties": { "body_text": { "type": "text", "index_prefixes": { } } } } }
此示例使用自定义前缀长度设置
resp = client.indices.create( index="my-index-000001", mappings={ "properties": { "full_name": { "type": "text", "index_prefixes": { "min_chars": 1, "max_chars": 10 } } } }, ) print(resp)
response = client.indices.create( index: 'my-index-000001', body: { mappings: { properties: { full_name: { type: 'text', index_prefixes: { min_chars: 1, max_chars: 10 } } } } } ) puts response
const response = await client.indices.create({ index: "my-index-000001", mappings: { properties: { full_name: { type: "text", index_prefixes: { min_chars: 1, max_chars: 10, }, }, }, }, }); console.log(response);
PUT my-index-000001 { "mappings": { "properties": { "full_name": { "type": "text", "index_prefixes": { "min_chars" : 1, "max_chars" : 10 } } } } }