Percolator - Adding metadata to query

I'm building my queries using SearchSourceBuilder and saving the query into ES as type .percolator - works great.

Now, I want to add metadata to my query, so my query looks something like below;

{  
  "query":{  
    "match":{  
      "author":"vonnegut"
    },
    "userid":"1"
  }
}

However, I don't see an option to do this in SearchSourceBuilder. Am I missing something, or there is another Builder I should be using?

PS: The idea is that, if multiple users are interested in 1 topic, it makes sense to me to create one percolate query and save those user's metadata in the query.

The best way to achieve this is to not use the SearchSourceBuilder but use the XContentBuilder to construct the percolator query document yourself. In order to add the query you use one of the query builders and add that to the XContentBuilder under the query field.

Thanks @mvg.

What is the best way to extract the additional metadata later on. As far as I can see, the percolate API returns the _id field and _index field for all matched queries. Is the idea then to query the type .percolator with the returned ids, or is there a way better way?

At the moment the percolator api can only return the _index and _id of the matched queries.
At some point the percolator api will be improved to return the entire query or a part of it: