WARNING: Version 2.1 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Token count datatype
editToken count datatype
editA field of type token_count
is really an integer
field which
accepts string values, analyzes them, then indexes the number of tokens in the
string.
For instance:
PUT my_index { "mappings": { "my_type": { "properties": { "name": { "type": "string", "fields": { "length": { "type": "token_count", "analyzer": "standard" } } } } } } } PUT my_index/my_type/1 { "name": "John Smith" } PUT my_index/my_type/2 { "name": "Rachel Alice Williams" } GET my_index/_search { "query": { "term": { "name.length": 3 } } }
The |
|
The |
|
This query matches only the document containing |
Technically the token_count
type sums position increments rather than
counting tokens. This means that even if the analyzer filters out stop
words they are included in the count.
Parameters for token_count
fields
editThe following parameters are accepted by token_count
fields:
The analyzer which should be used to analyze the string value. Required. For best performance, use an analyzer without token filters. |
|
Field-level index time boosting. Accepts a floating point number, defaults
to |
|
Should the field be stored on disk in a column-stride fashion, so that it
can later be used for sorting, aggregations, or scripting? Accepts |
|
Should the field be searchable? Accepts |
|
Whether or not the field value should be included in the
|
|
Accepts a numeric value of the same |
|
Controls the number of extra terms that are indexed to make
|
|
Whether the field value should be stored and retrievable separately from
the |