Package org.elasticsearch.action.index

Examples of org.elasticsearch.action.index.IndexRequestBuilder.execute()


        Object document = extractDocumentFromMessage(exchange.getIn());

        if (!setIndexRequestSource(document, prepareIndex)) {
            throw new ExpectedBodyTypeException(exchange, XContentBuilder.class);
        }
        ListenableActionFuture<IndexResponse> future = prepareIndex.execute();
        IndexResponse response = future.actionGet();
        exchange.getIn().setBody(response.getId());
    }

    public void addToIndexUsingBulk(Client client, Exchange exchange) {
View Full Code Here


      IndexRequestBuilder irb = client().prepareIndex(appid, so.getType(), so.getId()).
          setSource(data).setRouting(so.getShardKey());
      if (ttl > 0) {
        irb.setTTL(ttl);
      }
      irb.execute().actionGet();
      logger.debug("Search.index() {}", so.getId());
    } catch (Exception e) {
      logger.warn(null, e);
    }
  }
View Full Code Here

        Object document = extractDocumentFromMessage(exchange.getIn());

        if (!setIndexRequestSource(document, prepareIndex)) {
            throw new ExpectedBodyTypeException(exchange, XContentBuilder.class);
        }
        ListenableActionFuture<IndexResponse> future = prepareIndex.execute();
        IndexResponse response = future.actionGet();
        exchange.getIn().setBody(response.getId());
    }

    public void addToIndexUsingBulk(Client client, Exchange exchange) {
View Full Code Here

    private String add(String index, String type, String routing, String json) {
        IndexRequestBuilder req =  client.prepareIndex(index, type).setSource(json);
        if (routing != null)
            req.setRouting(routing);
       
        IndexResponse rsp = req.execute().actionGet();
        return rsp.getId();
    }

    private void refresh(String index) {
        client.admin().indices().refresh(new RefreshRequest(index)).actionGet();
View Full Code Here

            documentRevision = generateRevisionNumber();
            document.put("_rev", documentRevision);
        }
        IndexRequestBuilder indexBuilder = client.prepareIndex(index, docType, docId);
        indexBuilder.setSource(document);
        IndexResponse response = indexBuilder.execute().actionGet();
        if(response != null) {
            return documentRevision;
        }
        return null;
    }
View Full Code Here

        builder.setType(this.checkpointDocumentType);
        builder.setSource(toBeIndexed);
        builder.setOpType(OpType.CREATE);

        IndexResponse response;
        ListenableActionFuture<IndexResponse> laf = builder.execute();
        if(laf != null) {
            response = laf.actionGet();
            if(!response.isCreated()) {
                logger.error("did not succeed creating uuid");
            }
View Full Code Here

        builder.setType(this.checkpointDocumentType);
        builder.setSource(toBeIndexed);
        builder.setOpType(OpType.CREATE);

        IndexResponse response;
        ListenableActionFuture<IndexResponse> laf = builder.execute();
        if(laf != null) {
            response = laf.actionGet();
            if(!response.isCreated()) {
                logger.error("did not succeed creating uuid");
            }
View Full Code Here

                        PERCOLATOR_TYPE,
                        queryName)
                        .setSource(source)
                        .setRefresh(immediatelyAvailable);

        return percolatorRequest.execute().actionGet();
    }

    /**
     * Create Percolator
     *
 
View Full Code Here

                        PERCOLATOR_TYPE,
                        queryName)
                        .setSource("{\"query\": " + query + "}")
                        .setRefresh(immediatelyAvailable);

        return percolatorRequest.execute().actionGet();
    }


    /**
     * Check if a percolator exists
View Full Code Here

        IndexRequestBuilder prepareIndex = client.prepareIndex(indexName, indexType);

        if (!setIndexRequestSource(exchange.getIn(), prepareIndex)) {
            throw new ExpectedBodyTypeException(exchange, XContentBuilder.class);
        }
        ListenableActionFuture<IndexResponse> future = prepareIndex.execute();
        IndexResponse response = future.actionGet();
        exchange.getIn().setBody(response.getId());
    }

    @SuppressWarnings("unchecked")
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.