Hello Darren ,
Following query does what you have asked for ( replace FIELD with the field
you are looking for) -
{
"fields": [
"text"
],
"query": {
"term": {
"text": "god"
}
},
"script_fields": {
"tf": {
"script": "_index['FIELD']['cat'].tf()"
}
}
}
For the second one , use -
{
"query": {
"term": {
"FIELD": "CAT"
}
},
"aggs": {
"groupName": {
"terms": {
"field": "GROUP_FIELD"
},
"aggs": {
"catStats": {
"sum": {
"script": "_index['FIELD']['CAT'].tf()"
}
}
}
}
}
}
Thanks
Vineeth
On Mon, Sep 8, 2014 at 6:24 PM, Darren Trzynka <[email protected]>
wrote:
> Vineeth,
> Thanks for responding. What I am looking for is provided I perform a
> search for various terms, how given the search result can I understand the
> frequency of the hits within documents. For example, I perform a full text
> search on cat. 5 documents are returned. I could today get the terms that
> were found highlighted but that is of course quite nasty. Instead what I
> would like returned is the documents but something like for each document
> saying:
> Document 1 (group: 1): cat - 5
> Document 2 (group: 2): cat - 3
> Document 3 (group: 1): cat - 2
> ...
> Document n - cat - #
>
> Also, there is other metadata that it would be nice to aggregate on too so
> I could get an answer for the above scenario:
> group : 1 - cat - 7
> group : 2 - cat - 3
>
> Thanks
> Darren
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/76044495-afc9-4c51-b3f3-6ea7e636bc01%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/76044495-afc9-4c51-b3f3-6ea7e636bc01%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3DfRzwke0GK_pn8WxPBJ6c%2B97yOyDPmkXcWkQJf%3Dy5rfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.