Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchResponse.hits()


                            logger.warn("Doc {} has different version numbers {} and {}", hit.id(), version, getResponse.version());
                        }
                    }
                }
            }
            if (searchResponse.hits().hits().length == 0) {
                break;
            }
        }
        logger.info("Done verifying versions");
View Full Code Here


        client.client().admin().indices().prepareRefresh().execute().actionGet();
        for (int i = 0; i < NUMBER_OF_DOCS; i++) {
            String id = Integer.toString(i);
            for (int j = 0; j < 5; j++) {
                SearchResponse response = client.client().prepareSearch().setQuery(QueryBuilders.termQuery("_id", id)).execute().actionGet();
                if (response.hits().totalHits() > 1) {
                    System.err.println("[" + i + "] FAIL, HITS [" + response.hits().totalHits() + "]");
                }
            }
            GetResponse getResponse = client.client().prepareGet("test", "type1", id).execute().actionGet();
            if (getResponse.exists()) {
View Full Code Here

        for (int i = 0; i < NUMBER_OF_DOCS; i++) {
            String id = Integer.toString(i);
            for (int j = 0; j < 5; j++) {
                SearchResponse response = client.client().prepareSearch().setQuery(QueryBuilders.termQuery("_id", id)).execute().actionGet();
                if (response.hits().totalHits() > 1) {
                    System.err.println("[" + i + "] FAIL, HITS [" + response.hits().totalHits() + "]");
                }
            }
            GetResponse getResponse = client.client().prepareGet("test", "type1", id).execute().actionGet();
            if (getResponse.exists()) {
                long version = getResponse.version();
View Full Code Here

                    SearchResponse searchResponse = builder.execute().actionGet();
                    if (searchResponse.failedShards() > 0) {
                        logger.warn("failed search " + Arrays.toString(searchResponse.shardFailures()));
                    }
                    // verify that all come from the requested index
                    for (SearchHit hit : searchResponse.hits()) {
                        if (!hit.shard().index().equals(indexName)) {
                            logger.warn("got wrong index, asked for [{}], got [{}]", indexName, hit.shard().index());
                        }
                    }
                    // verify that all has the relevant value
View Full Code Here

                        if (!hit.shard().index().equals(indexName)) {
                            logger.warn("got wrong index, asked for [{}], got [{}]", indexName, hit.shard().index());
                        }
                    }
                    // verify that all has the relevant value
                    for (SearchHit hit : searchResponse.hits()) {
                        if (!value.equals(hit.sourceAsMap().get("field"))) {
                            logger.warn("got wrong field, asked for [{}], got [{}]", value, hit.sourceAsMap().get("field"));
                        }
                    }
                    Thread.sleep(searcherThrottle.millis());
View Full Code Here

            // verify search
            for (int i = 0; i < (nodes.length * 5); i++) {
                // do a search with norms field, so we don't rely on match all filtering cache
                SearchResponse search = client.client().prepareSearch().setQuery(matchAllQuery().normsField("field")).execute().actionGet();
                logger.debug("index_count [{}], expected_count [{}]", search.hits().totalHits(), indexCounter.get());
                if (count.count() != indexCounter.get()) {
                    logger.warn("!!! search does not match, index_count [{}], expected_count [{}]", search.hits().totalHits(), indexCounter.get());
                    throw new Exception("failed test, count does not match...");
                }
            }
View Full Code Here

            for (int i = 0; i < (nodes.length * 5); i++) {
                // do a search with norms field, so we don't rely on match all filtering cache
                SearchResponse search = client.client().prepareSearch().setQuery(matchAllQuery().normsField("field")).execute().actionGet();
                logger.debug("index_count [{}], expected_count [{}]", search.hits().totalHits(), indexCounter.get());
                if (count.count() != indexCounter.get()) {
                    logger.warn("!!! search does not match, index_count [{}], expected_count [{}]", search.hits().totalHits(), indexCounter.get());
                    throw new Exception("failed test, count does not match...");
                }
            }

            logger.info("*** ROUND {}", ++numberOfRounds);
View Full Code Here

        assertThat(searchResponse.hits().getAt(1).id(), equalTo("3"));
        assertThat(searchResponse.hits().getAt(2).id(), equalTo("4"));
        assertThat(searchResponse.hits().getAt(3).id(), equalTo("5"));
        assertThat(searchResponse.hits().getAt(4).id(), equalTo("6"));
        assertThat(searchResponse.hits().getAt(5).id(), equalTo("2"));
        assertThat(searchResponse.hits().getAt(6).id(), equalTo("7"));

        searchResponse = client.prepareSearch().setQuery(matchAllQuery())
                .addSort(SortBuilders.geoDistanceSort("location").point(40.7143528, -74.0059731).order(SortOrder.DESC))
                .execute().actionGet();
View Full Code Here

        assertThat(searchResponse.hits().hits().length, equalTo(1));
        assertThat(searchResponse.hits().getAt(0).fields().size(), equalTo(1));
        assertThat(searchResponse.hits().getAt(0).fields().get("field3").value().toString(), equalTo("value3"));

        searchResponse = client.prepareSearch().setQuery(matchAllQuery()).addField("*").execute().actionGet();
        assertThat(searchResponse.hits().getTotalHits(), equalTo(1l));
        assertThat(searchResponse.hits().hits().length, equalTo(1));
        assertThat(searchResponse.hits().getAt(0).fields().size(), equalTo(2));
        assertThat(searchResponse.hits().getAt(0).fields().get("field1").value().toString(), equalTo("value1"));
        assertThat(searchResponse.hits().getAt(0).fields().get("field3").value().toString(), equalTo("value3"));
    }
View Full Code Here

        searchResponse = client.prepareSearch().setQuery(matchAllQuery())
                .addSort(SortBuilders.geoDistanceSort("location").point(40.7143528, -74.0059731).order(SortOrder.DESC))
                .execute().actionGet();

        assertThat(searchResponse.hits().getTotalHits(), equalTo(7l));
        assertThat(searchResponse.hits().hits().length, equalTo(7));
        assertThat(searchResponse.hits().getAt(6).id(), equalTo("1"));
        assertThat(searchResponse.hits().getAt(5).id(), equalTo("3"));
        assertThat(searchResponse.hits().getAt(4).id(), equalTo("4"));
        assertThat(searchResponse.hits().getAt(3).id(), equalTo("5"));
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.