index_prefixes
index_prefixes
The index_prefixes
parameter enables the indexing of term prefixes to speed up prefix searches. It accepts the following optional settings:
| The minimum prefix length to index. Must be greater than 0, and defaults to 2. The value is inclusive. |
| The maximum prefix length to index. Must be less than 20, and defaults to 5. The value is inclusive. |
This example creates a text field using the default prefix length settings:
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": { }
}
}
}
}
An empty settings object will use the default |
This example uses custom prefix length settings:
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
}
}
}
}
}
当前内容版权归 elasticsearch 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 elasticsearch .