Examples of prepareBulk()


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

            System.out.println("--> Indexing [" + COUNT + "] ...");
            long iters = COUNT / BATCH;
            long i = 1;
            int counter = 0;
            for (; i <= iters; i++) {
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < BATCH; j++) {
                    counter++;
                    final long value = lValues[r.nextInt(lValues.length)];
                    XContentBuilder source = jsonBuilder().startObject()
                            .field("id", Integer.valueOf(counter))
View Full Code Here

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

            System.out.println("Indexing " + NUM_DOCS + " documents");

            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) {
                    final int lowCard = RandomInts.randomInt(R, LOW_CARD);
                    final int highCard = RandomInts.randomInt(R, HIGH_CARD);
                    request.add(client.prepareIndex("index", "type", Integer.toString(i)).setSource("low_card_str_value", "str" + lowCard, "high_card_str_value", "str" + highCard, "low_card_num_value", lowCard , "high_card_num_value", highCard));
                    ++i;
View Full Code Here

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

            String[] sValues = uniqueTerms.toArray(String.class);
            long ITERS = COUNT / BATCH;
            long i = 1;
            int counter = 0;
            for (; i <= ITERS; i++) {
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < BATCH; j++) {
                    counter++;

                    XContentBuilder builder = jsonBuilder().startObject();
                    builder.field("id", Integer.toString(counter));
View Full Code Here

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

        System.out.println("Indexing [" + COUNT + "] ...");
        long ITERS = COUNT / BATCH;
        long i = 1;
        int counter = 0;
        for (; i <= ITERS; i++) {
            BulkRequestBuilder request = client1.prepareBulk();
            for (int j = 0; j < BATCH; j++) {
                counter++;
                request.add(Requests.indexRequest("test").type("type1").id(autoGenerateId ? null : Integer.toString(counter)).source(source(Integer.toString(counter), "test" + counter)));
            }
            BulkResponse response = request.execute().actionGet();
View Full Code Here

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

            long i = 1;
            char character = 'a';
            int idCounter = 0;
            for (; i <= ITERS; i++) {
                int termCounter = 0;
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < BATCH; j++) {
                    request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(idCounter++)).source(source("prefix" + character + termCounter++)));
                }
                character++;
                BulkResponse response = request.execute().actionGet();
View Full Code Here

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

            } catch (IndexAlreadyExistsException e) {}
            client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();


            System.out.println("--> indexing: " + NUM_DOCS + " documents...");
            BulkRequestBuilder bulkBuilder = client.prepareBulk();
            for (int i = 0; i < NUM_DOCS; i++) {
                bulkBuilder.add(client.prepareIndex(INDEX, "doc").setSource("num", i));
                if (i % BULK_SIZE == 0) {
                    // Send off bulk request
                    bulkBuilder.get();
View Full Code Here

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

                bulkBuilder.add(client.prepareIndex(INDEX, "doc").setSource("num", i));
                if (i % BULK_SIZE == 0) {
                    // Send off bulk request
                    bulkBuilder.get();
                    // Create a new holder
                    bulkBuilder = client.prepareBulk();
                }
            }
            bulkBuilder.get();
            client.admin().indices().prepareRefresh(INDEX).get();
            SearchResponse countResp = client.prepareSearch(INDEX).setQuery(matchAllQuery()).setSearchType(SearchType.COUNT).get();
View Full Code Here

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

                .get();
        client.admin().indices().prepareCreate(INDEX_NAME)
                .addMapping(TYPE_NAME, MAPPING)
                .get();

        BulkRequestBuilder builder = client.prepareBulk();
        int fieldCount = 0;
        long time = System.currentTimeMillis();
        final int PRINT = 1000;
        for (int i = 0; i < DOC_COUNT; i++) {
            XContentBuilder sourceBuilder = jsonBuilder().startObject();
View Full Code Here

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

                            .setSource(sourceBuilder)
            );

            if (builder.numberOfActions() >= 1000) {
                builder.get();
                builder = client.prepareBulk();
            }

            if (i % PRINT == 0) {
                long took = System.currentTimeMillis() - time;
                time = System.currentTimeMillis();
View Full Code Here

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

            System.out.println("--> Indexing [" + rootDocs + "] root documents and [" + (rootDocs * nestedCount) + "] nested objects");
            long ITERS = rootDocs / batch;
            long i = 1;
            int counter = 0;
            for (; i <= ITERS; i++) {
                BulkRequestBuilder request = client.prepareBulk();
                for (int j = 0; j < batch; j++) {
                    counter++;
                    XContentBuilder doc = XContentFactory.jsonBuilder().startObject()
                            .field("field1", counter)
                            .startArray("field2");
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.