* @return
* @throws IOException
*/
public static List<String> getPercolatorsForDoc(Index indexable) {
PercolateRequestBuilder percolateRequestBuilder = new PercolateRequestBuilder(IndexClient.client);
percolateRequestBuilder.setDocumentType(indexable.getIndexPath().type);
XContentBuilder doc = null;
try {
doc = jsonBuilder().startObject().startObject("doc").startObject(indexable.getIndexPath().type);
Map<String, Object> map = indexable.toIndex();
for (String key : map.keySet()) {
if (key != null && map.get(key) != null) {
doc.field(key, map.get(key));
}
}
doc.endObject().endObject().endObject();
} catch (Exception e) {
Logger.debug("Elasticsearch : Error when get percolator for ");
}
percolateRequestBuilder.setSource(doc);
PercolateResponse percolateResponse = percolateRequestBuilder.execute().actionGet();
if (percolateResponse == null) {
return null;
}
List<String> matchedQueryIds = new ArrayList<String>();
PercolateResponse.Match[] matches = percolateResponse.getMatches();