Java Api percolate with aggregations


I am running percolate action and it's works greate but.. when I am trying to add aggregation to percolate request but its returns with no matches.

PercolateResponse response = client.preparePercolate()

My percolator mapping is:

  PUT news-feed-index/.percolator/_mapping
        ".percolator" : {
                "properties" : {
                        "query" : {
                                "type" : "object",
                                "enabled" : false
                        "usersRuleState" : { 
                            "type": "nested",
                            "properties": {
                                "user": {"type": "string"},
                                "isActive": {"type": "boolean"}
                        "filter": {"type": "string"},
                        "owner": {"type": "string"},
                        "ruleName": {"type": "string"}

and I am trying to do this but in Java Api:

POST /news-feed-index/news/_percolate/
  "doc": {
 "subject": "Murder in Mexico",
 "body": "",
  "size": 0, 
"aggs" : { 
    "users" : { 
        "terms" : { 
          "field" : "user"

Any help?

(Martijn Van Groningen) #2

Can you try to use PercolateSourceBuilder the build request body and then set that directly on the request? the addAggregation(...) and other builder methods undo what has been set via setSource(...) method.

Something like this:

PercolateSourceBuilder sourceBuilder = new PercolateSourceBuilder()



I solved it other way.
After I read I understand that the problem is in setSource().

   PercolateResponse response = client.preparePercolate()
.setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc(doc) )

This is solved it.

(system) #4