Package org.elasticsearch.action.percolate

Examples of org.elasticsearch.action.percolate.PercolateRequestBuilder


     * @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();
View Full Code Here


     * @return
     * @throws IOException
     */
    public static List<String> getPercolatorsForDoc(Index indexable) {

        PercolateRequestBuilder percolateRequestBuilder = new PercolateRequestBuilder(IndexClient.client, indexable.getIndexPath().index, 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;
        }
        return percolateResponse.getMatches();
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.percolate.PercolateRequestBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.