Package org.elasticsearch.client

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


                    bulkBuilder = client.prepareBulk();
                }
            }
            bulkBuilder.get();
            client.admin().indices().prepareRefresh(INDEX).get();
            SearchResponse countResp = client.prepareSearch(INDEX).setQuery(matchAllQuery()).setSearchType(SearchType.COUNT).get();
            assert countResp.getHits().getTotalHits() == NUM_DOCS : "all docs should be indexed";

            final int warmupCount = 100;
            for (int i = 0; i < warmupCount; i++) {
                if (i % 15 == 0) {
View Full Code Here


            final int warmupCount = 100;
            for (int i = 0; i < warmupCount; i++) {
                if (i % 15 == 0) {
                    System.out.println("--> warmup #" + i);
                }
                SearchResponse resp = client.prepareSearch(INDEX).setQuery(matchAllQuery())
                        .addAggregation(
                                terms("myterms")
                                        .size(AGG_SIZE)
                                        .field("num")
                        ).setSearchType(SearchType.COUNT).get();
View Full Code Here

        System.out.println("--> Used heap size: " + statsResponse.getNodes()[0].getJvm().getMem().getHeapUsed());

        System.out.println("--> Running match_all with sorting on nested field");
        // run just the child query, warm up first
        for (int j = 0; j < queryWarmup; j++) {
            SearchResponse searchResponse = client.prepareSearch()
                    .setQuery(matchAllQuery())
                    .addSort(
                            SortBuilders.fieldSort("field2.field3")
                                    .setNestedPath("field2")
                                    .sortMode("avg")
View Full Code Here

            }
        }

        long totalQueryTime = 0;
        for (int j = 0; j < queryCount; j++) {
            SearchResponse searchResponse = client.prepareSearch()
                    .setQuery(matchAllQuery())
                    .addSort(
                            SortBuilders.fieldSort("field2.field3")
                                    .setNestedPath("field2")
                                    .sortMode("avg")
View Full Code Here

        client.admin().indices().prepareRefresh(indexName).get();
        System.out.printf(Locale.ENGLISH, "--> Number of docs in index: %d\n", client.prepareCount().get().getCount());

        Long counter = numDocs;
        SearchResponse searchResponse = client.prepareSearch(indexName)
                .addSort("field1", SortOrder.DESC)
                .setSize(requestSize)
                .setScroll("10m").get();

        if (searchResponse.getHits().getTotalHits() != numDocs) {
View Full Code Here

        System.out.println("--> Number of docs in index: " + client.prepareCount(indexName).setQuery(matchAllQuery()).execute().actionGet().getCount());

        System.out.println("--> Running just child query");
        // run just the child query, warm up first
        for (int i = 1; i <= 10000; i *= 2) {
            SearchResponse searchResponse = client.prepareSearch(indexName).setQuery(matchQuery("child.field2", i)).execute().actionGet();
            System.out.println("--> Warmup took["+ i +"]: " + searchResponse.getTook());
            if (searchResponse.getHits().totalHits() != i) {
                System.err.println("--> mismatch on hits");
            }
        }
View Full Code Here

        System.out.println("--> Committed heap size: " + statsResponse.getNodes()[0].getJvm().getMem().getHeapCommitted());
        System.out.println("--> Used heap size: " + statsResponse.getNodes()[0].getJvm().getMem().getHeapUsed());

        // run parent child constant query
        for (int j = 1; j < QUERY_WARMUP; j *= 2) {
            SearchResponse searchResponse = client.prepareSearch(indexName)
                    .setQuery(
                            hasChildQuery("child", matchQuery("field2", j))
                    )
                    .execute().actionGet();
            if (searchResponse.getFailedShards() > 0) {
View Full Code Here

        }

        long totalQueryTime = 0;
        for (int i = 1; i < PARENT_COUNT; i *= 2) {
            for (int j = 0; j < QUERY_COUNT; j++) {
                SearchResponse searchResponse = client.prepareSearch(indexName)
                        .setQuery(filteredQuery(matchAllQuery(), hasChildFilter("child", matchQuery("field2", i))))
                        .execute().actionGet();
                if (searchResponse.getHits().totalHits() != i) {
                    System.err.println("--> mismatch on hits");
                }
View Full Code Here

        System.out.println("--> Used heap size: " + statsResponse.getNodes()[0].getJvm().getMem().getHeapUsed());

        totalQueryTime = 0;
        for (int i = 1; i < PARENT_COUNT; i *= 2) {
            for (int j = 0; j < QUERY_COUNT; j++) {
                SearchResponse searchResponse = client.prepareSearch(indexName)
                        .setQuery(hasChildQuery("child", matchQuery("field2", i)).scoreType("max"))
                        .execute().actionGet();
                if (searchResponse.getHits().totalHits() != i) {
                    System.err.println("--> mismatch on hits");
                }
View Full Code Here

            for (Map.Entry<String, Object> entry : percentilesUnsorted.entrySet()) {
                percentiles.put(Double.parseDouble(entry.getKey()), (Double) entry.getValue());
            }
            System.out.println("Expected percentiles: " + percentiles);
            System.out.println();
            SearchResponse resp = client.prepareSearch(d.indexName()).setSearchType(SearchType.COUNT).addAggregation(percentiles("pcts").field("v").percentiles(PERCENTILES)).execute().actionGet();
            Percentiles pcts = resp.getAggregations().get("pcts");
            Map<Double, Double> asMap = Maps.newLinkedHashMap();
            double sumOfErrorSquares = 0;
            for (Percentile percentile : pcts) {
                asMap.put(percentile.getPercent(), percentile.getValue());
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.