| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | [[percolate]]== Percolate APIThe percolator allows one to register queries against an index, and thensend `percolate` requests which include a doc, getting back thequeries that match on that doc out of the set of registered queries.Read the main {ref}/search-percolate.html[percolate]documentation before reading this guide.[source,java]--------------------------------------------------//This is the query we're registering in the percolatorQueryBuilder qb = termQuery("content", "amazing");//Index the query = register it in the percolatorclient.prepareIndex("myIndexName", ".percolator", "myDesignatedQueryName")    .setSource(jsonBuilder()        .startObject()            .field("query", qb) // Register the query        .endObject())    .setRefresh(true) // Needed when the query shall be available immediately    .execute().actionGet();--------------------------------------------------This indexes the above term query under the name*myDesignatedQueryName*.In order to check a document against the registered queries, use thiscode:[source,java]--------------------------------------------------//Build a document to check against the percolatorXContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();docBuilder.field("doc").startObject(); //This is needed to designate the documentdocBuilder.field("content", "This is amazing!");docBuilder.endObject(); //End of the doc fielddocBuilder.endObject(); //End of the JSON root object//PercolatePercolateResponse response = client.preparePercolate()                        .setIndices("myIndexName")                        .setDocumentType("myDocumentType")                        .setSource(docBuilder).execute().actionGet();//Iterate over the resultsfor(PercolateResponse.Match match : response) {    //Handle the result which is the name of    //the query in the percolator}--------------------------------------------------
 |