Actually i want to aggreagate by "name" of keywords field. However I only want those keywords which are of type "general hashtag word". I am using this query { "from" : 0, "size" : 0, "query" : { "filtered" : { "query" : { "match_all" : { } }, "filter" : { "bool" : { "must" : [ { "term" : { "brand_context_id" : "4" } },{ "nested" : { "filter" : { "term" : { "keywords.type" : "general hashtag word" } }, "path" : "keywords" } } ] } } } }, "aggregations" : { "keywords" : { "nested" : { "path" : "keywords" }, "aggregations" : { "keywords_count" : { "terms" : { "field" : "keywords.name", "size": 0 } } } } } } This agggregate is also giving keywords which are not marked as type "general hashtag word". How can I only aggregate by kewords which are marked as type "general hashtag word" On Thursday, November 27, 2014 12:05:15 AM UTC+5:30, Vijay Tiwary wrote:
> I storing documents as shown below: > "keywords": [ > { > "name": "#nfl", > "type": "general hashtag word", > "postag": "nnp" > }, > { > "name": "#bill", > "type": "general hashtag word", > "postag": "nnp" > }, > { > "name": "video", > "type": "general word noun "keywords" is nested > fieldchunk", > "postag": "noun" > } > ] > *"keywords" is nested field* > Now how can I query so that the document returned should only have those > objects from the "keywords" field which has "type" as "general hashtag word" > > I am trying the following query . However with this query all the objects > are returned if any one of the object in the keywords field have type as > "general hashtag word" > { > "size":20, > > "query" : { > "filtered" : { > "filter" : { > "nested" : { > "path" : "keywords", > "filter" : { > > "term" : {"type" : "general hashtag word" } > } > > > } > } > } > } > } > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/5aa37181-30ea-4163-8baf-9271ee19fd8a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.