Package org.elasticsearch.action.index

Examples of org.elasticsearch.action.index.IndexResponse


        id = in.readVInt();
        opType = in.readUTF();

        byte type = in.readByte();
        if (type == 0) {
            response = new IndexResponse();
            response.readFrom(in);
        } else if (type == 1) {
            response = new DeleteResponse();
            response.readFrom(in);
        }
View Full Code Here


                            builder.field(Fields.ERROR, itemResponse.failure().message());
                        } else {
                            builder.field(Fields.OK, true);
                        }
                        if (itemResponse.response() instanceof IndexResponse) {
                            IndexResponse indexResponse = itemResponse.response();
                            if (indexResponse.matches() != null) {
                                builder.startArray(Fields.MATCHES);
                                for (String match : indexResponse.matches()) {
                                    builder.value(match);
                                }
                                builder.endArray();
                            }
                        }
View Full Code Here

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

  protected void flushIndex() {
    nodeTemplate.flushIndex();
  }

  protected IndexResponse index(final XContentBuilder content) {
    final IndexResponse response = nodeTemplate.executeGet(new ClientCallback<IndexResponse>() {

      @Override
      public ActionFuture<IndexResponse> execute(final Client client) {
        final IndexRequest request = Requests.indexRequest(nodeTemplate.getIndexName())
                                             .source(content).type("log");
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();
    }
View Full Code Here

        String topic = request.hasParam("topic") ? request.paramAsString("topic") : "*";
        try {
            // advertise phase - save message in the index (for disconnected subscribers)
            final XContentBuilder messageBuilder = createPublishMessage(request);
            final XContentBuilder responseBuilder = jsonBuilder().startObject();
            IndexResponse indexResponse = client.prepareIndex()
                    .setIndex(pubSubIndexName)
                    .setType(TYPE)
                    .setSource(messageBuilder)
                    .setRefresh(request.paramAsBoolean("refresh", true))
                    .execute().actionGet();
            responseBuilder.field("id", indexResponse.getId());
            // push phase - scroll over subscribers for this topic currently connected
            QueryBuilder queryBuilder = termQuery("topic", topic);
            SearchResponse searchResponse = client.prepareSearch()
                    .setIndices(pubSubIndexName)
                    .setTypes("subscribe")
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.setId(id);
        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.setId(id);
        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

    // instance a json mapper
    ObjectMapper mapper = new ObjectMapper(); // create once, reuse

    Beer beer = new Beer("Heineken", Colour.PALE, 0.33, 3);
    IndexResponse ir = null;

    // generate a json content
    String jsonString = null;
    // TODO Serialize Beer to json

    // indexing document
    // TODO index the beer in meal index, beer type

    Assert.assertNotNull(ir);
    Assert.assertNotNull(ir.getId());

    GetResponse gr = null;
    // TODO get the beer we have just indexed

    Assert.assertNotNull(gr);
    Assert.assertNotNull(gr.getId());

    // We check that id are equals
    Assert.assertEquals(ir.getId(), gr.getId());

    Beer indexedBeer = null;
   
    // TODO Deserialize json indexed beer into a beer object
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.index.IndexResponse

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.