Counting the frequency of a term

I am almost new to ElasticSearch, and need to do a simple task. I want to
count the frequency of a word in a single document (not the number of
documents containing a term). Assume that my index consists of a single
document.

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/8902602c-d32c-407d-a180-368587d9fc46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

You can do this, but it involves scripting and is perhaps not very simple.
The frequency of a term in a document is given as
_index['FIELD']['TERM'].tf()

Combine this with a script field:

If you are willing to take the risk to enable dynamic scripting on your
box it can be done like this

{

"query": {

  "match_all": {}

},

"script_fields": {

  "qcount": {

     "script": "_index['FIELDNAME']['QUERYTERM'].tf()"

  },

  "qfield": {

     "script": "doc['FIELDNAME']"

  }

}

}

fredag 13. mars 2015 19.32.00 UTC+1 skrev reza sadoddin følgende:

I am almost new to Elasticsearch, and need to do a simple task. I want to
count the frequency of a word in a single document (not the number of
documents containing a term). Assume that my index consists of a single
document.

Thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/57ec332c-1df7-46d6-9999-87da9115f28e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.