Here is my ES Queries:
=== Create the index ===
PUT /sample
=== Insert Data ===
PUT /sample/docs/1
{"data": "And the world said, 'Disarm, disclose, or face serious consequences'—and therefore, we worked with the world, we worked to make sure that Saddam Hussein heard the message of the world."}
PUT /sample/docs/2
{"data": "Never give in — never, never, never, never, in nothing great or small, large or petty, never give in except to convictions of honor and good sense. Never yield to force; never yield to the apparently overwhelming might of the enemy"}
=== Query to Get Results ===
POST sample/docs/_search
{
"query": {
"match": {
"data": "never"
}
},
"highlight": {
"fields": {
"data":{}
}
}
}
=== Retrieved Result ===
...
"highlight": {
"data": [
"Never give in — never, never, never, never, in nothing great or small, large or petty, never give",
" in except to convictions of honour and good sense. Never yield to force; never yield to the apparently overwhelming might of the enemy"
]
}
=== Desired Result===
Required Term Frequency of searched term by document as example below
Doc Id: 2
Term Frequency :{
"never": 8
}
I have tried Bucket Aggregation, Terms Aggregation, and other Aggregations but I'm not getting this result. I have search over google and find way to use groovy script [_index] option but ES-5.6 not support groovy and I don't know how to convert groovy script to painless
Thanks for the help in advance!