2018-11-22 04:20:46 -05:00
|
|
|
[[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:
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
`min_chars`::
|
|
|
|
|
|
|
|
The minimum prefix length to index. Must be greater than 0, and defaults
|
|
|
|
to 2. The value is inclusive.
|
|
|
|
|
|
|
|
`max_chars`::
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2018-11-22 04:20:46 -05:00
|
|
|
--------------------------------
|
2020-07-27 15:58:26 -04:00
|
|
|
PUT my-index-000001
|
2018-11-22 04:20:46 -05:00
|
|
|
{
|
|
|
|
"mappings": {
|
2019-01-22 09:13:52 -05:00
|
|
|
"properties": {
|
|
|
|
"body_text": {
|
|
|
|
"type": "text",
|
|
|
|
"index_prefixes": { } <1>
|
2018-11-22 04:20:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
<1> An empty settings object will use the default `min_chars` and `max_chars`
|
|
|
|
settings
|
|
|
|
|
|
|
|
This example uses custom prefix length settings:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2018-11-22 04:20:46 -05:00
|
|
|
--------------------------------
|
2020-07-27 15:58:26 -04:00
|
|
|
PUT my-index-000001
|
2018-11-22 04:20:46 -05:00
|
|
|
{
|
|
|
|
"mappings": {
|
2019-01-22 09:13:52 -05:00
|
|
|
"properties": {
|
|
|
|
"full_name": {
|
|
|
|
"type": "text",
|
|
|
|
"index_prefixes": {
|
|
|
|
"min_chars" : 1,
|
|
|
|
"max_chars" : 10
|
2018-11-22 04:20:46 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------
|