Examples of prepareIndex()


Examples of org.elasticsearch.client.Client.prepareIndex()

      client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();

      String json = null;
      for (int i = 0; i < 10; i++) {
        json = "{\"ProductId\": \""+ i +"\", \"ProductName\": \"my product "+ i +"\" }";
        client.prepareIndex("test", "product").setSource(json).execute().actionGet();
      }
     
      client.admin().indices().prepareRefresh().execute().actionGet();
     
      // TODO Uncomment when Released
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

                for (int bulkCounter = 0; bulkCounter < 100; bulkCounter++) {
                    if (counter > numDocs) {
                        break;
                    }
                    bulkRequestBuilder.add(
                            client.prepareIndex(indexName, typeName, String.valueOf(counter))
                                    .setSource("field1", counter++)
                    );
                }
                int indexedDocs = counter - 1;
                if (indexedDocs % 100000 == 0) {
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            int id = 0;
            for (i = 1; i <= PARENT_COUNT; i *= 2) {
                int parentId = 1;
                for (int j = 0; j < i; j++) {
                    client.prepareIndex(indexName, "child", Integer.toString(id++))
                            .setParent(Integer.toString(parentId++))
                            .setSource(childSource(i))
                            .execute().actionGet();
                }
            }
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            System.out.println("Indexing " + NUM_DOCS + " documents into " + d.indexName());
            StopWatch stopWatch = new StopWatch().start();
            for (int i = 0; i < NUM_DOCS; ) {
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < BATCH && i < NUM_DOCS; ++j) {
                    request.add(client.prepareIndex(d.indexName(), "values", Integer.toString(i)).setSource("v", values[i]));
                    ++i;
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
View Full Code Here

Examples of org.elasticsearch.client.Client.prepareIndex()

            Arrays.sort(values);
            XContentBuilder builder = JsonXContent.contentBuilder().startObject();
            for (double percentile : PERCENTILES) {
                builder.field(Double.toString(percentile), accuratePercentile(percentile, values));
            }
            client.prepareIndex(d.indexName(), "values", "percentiles").setSource(builder.endObject()).execute().actionGet();
            client.admin().indices().prepareRefresh(d.indexName()).execute().actionGet();
        }

        ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
        if (clusterHealthResponse.isTimedOut()) {
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient.prepareIndex()

        final CountDownLatch latch = new CountDownLatch(1);
        Thread indexer = new Thread(new Runnable() {
            @Override public void run() {
                while (!done.get()) {
                    try {
                        client.prepareIndex("test", "type").setSource("field", "value").execute().actionGet();
                        indexed.incrementAndGet();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
View Full Code Here

Examples of org.elasticsearch.client.transport.TransportClient.prepareIndex()

            int numDocs = iterations(10, 100);
            IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs];
            for (int i = 0; i < numDocs; i++) {
                String id = "id" + i;
                indexRequestBuilders[i] = client.prepareIndex("test", "test", id).setSource("field", "value" + i);
            }
            indexRandom(false, indexRequestBuilders);

            String randomId = "id" + randomInt(numDocs-1);
            GetResponse getResponse = client.prepareGet("test", "test", randomId).get();
View Full Code Here

Examples of org.elasticsearch.index.shard.service.IndexShard.prepareIndex()

                    SourceToParse sourceToParse = SourceToParse.source(indexRequest.source()).type(indexRequest.type()).id(indexRequest.id())
                            .routing(indexRequest.routing()).parent(indexRequest.parent());
                    long version;
                    Engine.IndexingOperation op;
                    if (indexRequest.opType() == IndexRequest.OpType.INDEX) {
                        Engine.Index index = indexShard.prepareIndex(sourceToParse).version(indexRequest.version()).versionType(indexRequest.versionType()).origin(Engine.Operation.Origin.PRIMARY);
                        indexShard.index(index);
                        version = index.version();
                        op = index;
                    } else {
                        Engine.Create create = indexShard.prepareCreate(sourceToParse).version(indexRequest.version()).versionType(indexRequest.versionType()).origin(Engine.Operation.Origin.PRIMARY);
View Full Code Here

Examples of org.elasticsearch.index.shard.service.IndexShard.prepareIndex()

                IndexRequest indexRequest = (IndexRequest) item.request();
                try {
                    SourceToParse sourceToParse = SourceToParse.source(indexRequest.source()).type(indexRequest.type()).id(indexRequest.id())
                            .routing(indexRequest.routing()).parent(indexRequest.parent());
                    if (indexRequest.opType() == IndexRequest.OpType.INDEX) {
                        Engine.Index index = indexShard.prepareIndex(sourceToParse).version(indexRequest.version()).origin(Engine.Operation.Origin.REPLICA);
                        indexShard.index(index);
                    } else {
                        Engine.Create create = indexShard.prepareCreate(sourceToParse).version(indexRequest.version()).origin(Engine.Operation.Origin.REPLICA);
                        indexShard.create(create);
                    }
View Full Code Here

Examples of org.elasticsearch.index.shard.service.IndexShard.prepareIndex()

        SourceToParse sourceToParse = SourceToParse.source(request.source()).type(request.type()).id(request.id())
                .routing(request.routing()).parent(request.parent());
        long version;
        Engine.IndexingOperation op;
        if (request.opType() == IndexRequest.OpType.INDEX) {
            Engine.Index index = indexShard.prepareIndex(sourceToParse)
                    .version(request.version())
                    .versionType(request.versionType())
                    .origin(Engine.Operation.Origin.PRIMARY);
            indexShard.index(index);
            version = index.version();
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.