Package org.elasticsearch.action.bulk

Examples of org.elasticsearch.action.bulk.BulkResponse


                    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;
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                    System.err.println(response.buildFailureMessage());
                }
                if ((i % 100000) == 0) {
                    System.out.println("--> Indexed " + i + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
                }
View Full Code Here


                    }

                    request.add(Requests.indexRequest(indexName).type("type1").id(Integer.toString(counter))
                            .source(builder));
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                }
                if (((i * BATCH) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * BATCH));
                }
View Full Code Here

                    builder.endObject();

                    request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(counter))
                            .source(builder));
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                }
                if (((i * BATCH) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * BATCH) + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
View Full Code Here

                    builder.endObject();

                    request.add(Requests.indexRequest("test").type("type1").id(Integer.toString(counter))
                            .source(builder));
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                }
                if (((i * BATCH) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * BATCH) + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
View Full Code Here

                if (++parentDocument.indexCounter == parentDocument.queryValues.length) {
                    parents.remove(index);
                }
            }

            BulkResponse response = request.execute().actionGet();
            if (response.hasFailures()) {
                System.err.println("--> failures...");
            }

            indexCounter += response.getItems().length;
            if (indexCounter % 100000 == 0) {
                System.out.println("--> Indexed " + indexCounter + " documents");
            }
        }
    }
View Full Code Here

            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();
            if (response.hasFailures()) {
                System.err.println("failures...");
            }
            if (((i * BATCH) % 10000) == 0) {
                System.out.println("Indexed " + (i * BATCH) + " took " + stopWatch.stop().lastTaskTime());
                stopWatch.start();
View Full Code Here

                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();
                if (response.hasFailures()) {
                    System.err.println("failures...");
                }
            }
            System.out.println("Indexing took " + stopWatch.totalTime());

            client.admin().indices().prepareRefresh().execute().actionGet();
            System.out.println("Count: " + client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount());
        } catch (Exception e) {
            System.out.println("--> Index already exists, ignoring indexing phase, waiting for green");
            ClusterHealthResponse clusterHealthResponse = client.admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10m").execute().actionGet();
            if (clusterHealthResponse.isTimedOut()) {
                System.err.println("--> Timed out waiting for cluster health");
            }
            client.admin().indices().prepareRefresh().execute().actionGet();
            System.out.println("Count: " + client.prepareCount().setQuery(matchAllQuery()).execute().actionGet().getCount());
        }


        System.out.println("Warming up...");
        char startChar = 'a';
        for (int i = 0; i <= 20; i++) {
            String term = "prefix" + startChar;
            SearchResponse response = client.prepareSearch()
                    .setQuery(prefixQuery("field", term))
                    .addSuggestion(SuggestBuilders.termSuggestion("field").field("field").text(term).suggestMode("always"))
                    .execute().actionGet();
            if (response.getHits().totalHits() == 0) {
                System.err.println("No hits");
                continue;
            }
            startChar++;
        }


        System.out.println("Starting benchmarking suggestions.");
        startChar = 'a';
        long timeTaken = 0;
        for (int i = 0; i <= SEARCH_ITERS; i++) {
            String term = "prefix" + startChar;
            SearchResponse response = client.prepareSearch()
                    .setQuery(matchQuery("field", term))
                    .addSuggestion(SuggestBuilders.termSuggestion("field").text(term).field("field").suggestMode("always"))
                    .execute().actionGet();
            timeTaken += response.getTookInMillis();
            if (response.getSuggest() == null) {
                System.err.println("No suggestions");
                continue;
            }
            List<? extends Option> options = response.getSuggest().getSuggestion("field").getEntries().get(0).getOptions();
            if (options == null || options.isEmpty()) {
                System.err.println("No suggestions");
            }
            startChar++;
        }
View Full Code Here

                    doc = doc.endArray();
                    request.add(
                            Requests.indexRequest(indexName).type("type").id(Integer.toString(counter)).source(doc)
                    );
                }
                BulkResponse response = request.execute().actionGet();
                if (response.hasFailures()) {
                    System.err.println("--> failures...");
                }
                if (((i * batch) % 10000) == 0) {
                    System.out.println("--> Indexed " + (i * batch) + " took " + stopWatch.stop().lastTaskTime());
                    stopWatch.start();
View Full Code Here

            String jsonString = mapper.writeValueAsString(beer);
            irq.source(jsonString);
            brb.add(irq);
        }

        BulkResponse br = brb.execute().actionGet();
        Assert.assertFalse(br.hasFailures());

        node.client().admin().indices().prepareRefresh().execute().actionGet();
    }
View Full Code Here

            String jsonString = mapper.writeValueAsString(beer);
            irq.source(jsonString);
            brb.add(irq);
        }

        BulkResponse br = brb.execute().actionGet();
        Assert.assertFalse(br.hasFailures());

        node.client().admin().indices().prepareRefresh().execute().actionGet();
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.bulk.BulkResponse

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.