Skip to content

Commit

Permalink
Improve docs for index_prefixes option (#35778)
Browse files Browse the repository at this point in the history
This commit moves the documentation and examples for the `index_prefixes`
option on text fields to its own file, to bring it in line with other mapping 
parameters, and expands a bit on both.
  • Loading branch information
romseygeek authored Nov 22, 2018
1 parent 2887680 commit be8097f
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 35 deletions.
3 changes: 3 additions & 0 deletions docs/reference/mapping/params.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The following mapping parameters are common to some or all field datatypes:
* <<ignore-malformed,`ignore_malformed`>>
* <<index-options,`index_options`>>
* <<index-phrases,`index_phrases`>>
* <<index-prefixes,`index_prefixes`>>
* <<mapping-index,`index`>>
* <<multi-fields,`fields`>>
* <<norms,`norms`>>
Expand Down Expand Up @@ -66,6 +67,8 @@ include::params/index-options.asciidoc[]

include::params/index-phrases.asciidoc[]

include::params/index-prefixes.asciidoc[]

include::params/multi-fields.asciidoc[]

include::params/norms.asciidoc[]
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/mapping/params/index-phrases.asciidoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[[index-phrases]]
=== Index Phrases
=== `index_phrases`

If enabled, two-term word combinations ('shingles') are indexed into a separate
field. This allows exact phrase queries (no slop) to run more efficiently, at the expense
Expand Down
62 changes: 62 additions & 0 deletions docs/reference/mapping/params/index-prefixes.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[[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:

[source,js]
--------------------------------
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"body_text": {
"type": "text",
"index_prefixes": { } <1>
}
}
}
}
}
--------------------------------
// CONSOLE

<1> An empty settings object will use the default `min_chars` and `max_chars`
settings

This example uses custom prefix length settings:

[source,js]
--------------------------------
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"full_name": {
"type": "text",
"index_prefixes": {
"min_chars" : 1,
"max_chars" : 10
}
}
}
}
}
}
--------------------------------
// CONSOLE
35 changes: 2 additions & 33 deletions docs/reference/mapping/types/text.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ The following parameters are accepted by `text` fields:
What information should be stored in the index, for search and highlighting purposes.
Defaults to `positions`.

<<index-prefix-config,`index_prefixes`>>::
<<index-prefixes,`index_prefixes`>>::

If enabled, term prefixes of between 2 and 5 characters are indexed into a
separate field. This allows prefix searches to run more efficiently, at
the expense of a larger index. Accepts an
<<index-prefix-config,`index-prefix configuration block`>>
the expense of a larger index.

<<index-phrases,`index_phrases`>>::

Expand Down Expand Up @@ -142,33 +141,3 @@ The following parameters are accepted by `text` fields:

Whether term vectors should be stored for an <<mapping-index,`analyzed`>>
field. Defaults to `no`.

[[index-prefix-config]]
==== Index Prefix configuration

Text fields may also index term prefixes to speed up prefix searches. The `index_prefixes`
parameter is configured as below. Either or both of `min_chars` and `max_chars` may be excluded.
Both values are treated as inclusive

[source,js]
--------------------------------
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"full_name": {
"type": "text",
"index_prefixes" : {
"min_chars" : 1, <1>
"max_chars" : 10 <2>
}
}
}
}
}
}
--------------------------------
// CONSOLE
<1> `min_chars` must be greater than zero, defaults to 2
<2> `max_chars` must be greater than or equal to `min_chars` and less than 20, defaults to 5
2 changes: 1 addition & 1 deletion docs/reference/query-dsl/span-multi-term-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ GET /_search
WARNING: `span_multi` queries will hit too many clauses failure if the number of terms that match the query exceeds the
boolean query limit (defaults to 1024).To avoid an unbounded expansion you can set the <<query-dsl-multi-term-rewrite,
rewrite method>> of the multi term query to `top_terms_*` rewrite. Or, if you use `span_multi` on `prefix` query only,
you can activate the <<index-prefix-config,`index_prefixes`>> field option of the `text` field instead. This will
you can activate the <<index-prefixes,`index_prefixes`>> field option of the `text` field instead. This will
rewrite any prefix query on the field to a single term query that matches the indexed prefix.

0 comments on commit be8097f

Please sign in to comment.