Hi!
I am trying to add a new field into the ElasticSearch index to analyze and store the number of words a text has.
{
"settings": {
"analysis": {
"analyzer": {
"character_analyzer": {
"type": "custom",
"tokenizer": "character_tokenizer"
}
},
"tokenizer": {
"character_tokenizer": {
"type": "ngram",
"min_gram": 1,
"max_gram": 1
}
}
}
},
"mappings": {
"_doc": {
"dynamic": "strict",
"properties": {
"name": {
"type": "text",
"fields": {
"words_count": {
"type": "token_count",
"analyzer": "standard",
"store": true
}
Performing a query I am able to retrieve the documents which have the total words count I request in query:
{
"size": 1,
"query": {
"bool" : {
"must" : {
"range" : {
"name.words_count": {
"gt": 3
}
}
}
}
}
But I would like to retrieve this value on _source results. Is it possible? Am I missing something?
Thanks in advance!