- Java Transport Client (deprecated): other versions:
- Preface
- Maven Repository
- Client
- Index API
- Get API
- Delete API
- Bulk API
- Search API
- Count API
- Delete By Query API
- Facets
- Percolate API
- Query DSL - Queries
- Match Query
- MultiMatch Query
- Boolean Query
- Boosting Query
- IDs Query
- Constant Score Query
- Disjunction Max Query
- Fuzzy Like This (Field) Query (flt and flt_field)
- FuzzyQuery
- Has Child / Has Parent
- MatchAll Query
- More Like This (Field) Query (mlt and mlt_field)
- Prefix Query
- QueryString Query
- Range Query
- Span Queries (first, near, not, or, term)
- Term Query
- Terms Query
- Top Children Query
- Wildcard Query
- Nested Query
- Indices Query
- GeoShape Query
- Query DSL - Filters
- And Filter
- Bool Filter
- Exists Filter
- Ids Filter
- Limit Filter
- Type Filter
- Geo Bounding Box Filter
- GeoDistance Filter
- Geo Distance Range Filter
- Geo Polygon Filter
- Geo Shape Filter
- Has Child / Has Parent Filters
- Match All Filter
- Missing Filter
- Not Filter
- Or Filter
- Prefix Filter
- Query Filter
- Range Filter
- Script Filter
- Term Filter
- Terms Filter
- Nested Filter
- Caching
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Percolate API
editPercolate API
editThe percolator allows one to register queries against an index, and then
send percolate
requests which include a doc, getting back the
queries that match on that doc out of the set of registered queries.
Read the main percolate documentation before reading this guide.
//This is the query we're registering in the percolator QueryBuilder qb = termQuery("content", "amazing"); //Index the query = register it in the percolator client.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 this code:
//Build a document to check against the percolator XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject(); docBuilder.field("doc").startObject(); //This is needed to designate the document docBuilder.field("content", "This is amazing!"); docBuilder.endObject(); //End of the doc field docBuilder.endObject(); //End of the JSON root object //Percolate PercolateResponse response = client.preparePercolate() .setIndices("myIndexName") .setDocumentType("myDocumentType") .setSource(docBuilder).execute().actionGet(); //Iterate over the results for(PercolateResponse.Match match : response) { //Handle the result which is the name of //the query in the percolator }
Was this helpful?
Thank you for your feedback.