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 honour 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": [
"<em>Never</em> give in — <em>never</em>, <em>never</em>, <em>never</em>, <em>never</em>, in nothing great or small, large or petty, <em>never</em> give",
" in except to convictions of honour and good sense. <em>Never</em> yield to force; <em>never</em> 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.
Thanks for help in advance!