mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Improve docs for index_prefixes option (#35778)
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.
This commit is contained in:
parent
2887680acb
commit
be8097f9ce
@ -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`>>
|
||||
@ -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[]
|
||||
|
@ -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
|
||||
|
62
docs/reference/mapping/params/index-prefixes.asciidoc
Normal file
62
docs/reference/mapping/params/index-prefixes.asciidoc
Normal file
@ -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
|
@ -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`>>::
|
||||
|
||||
@ -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
|
||||
|
@ -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.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user