Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountResponse


        assertAllShardsOnNodes("test", backwardsCluster().backwardsNodePattern());

        logger.info("--> upgrade cluster");
        logClusterState();
        CountResponse countResponse = client().prepareCount().get();
        assertHitCount(countResponse, numDocs);

        client().admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableSettings.settingsBuilder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "none")).execute().actionGet();
        backwardsCluster().upgradeAllNodes();
        client().admin().cluster().prepareUpdateSettings().setTransientSettings(ImmutableSettings.settingsBuilder().put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE, "all")).execute().actionGet();
View Full Code Here


        assertThat(bField.size(), equalTo(2));
        assertThat(bField.get("type").toString(), equalTo("string"));
        assertThat(bField.get("index").toString(), equalTo("not_analyzed"));

        client().prepareIndex("my-index", "my-type", "1").setSource("a", "51,19").setRefresh(true).get();
        CountResponse countResponse = client().prepareCount("my-index")
                .setQuery(constantScoreQuery(geoDistanceFilter("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS)))
                .get();
        assertThat(countResponse.getCount(), equalTo(1l));
        countResponse = client().prepareCount("my-index").setQuery(matchQuery("a.b", "51,19")).get();
        assertThat(countResponse.getCount(), equalTo(1l));
    }
View Full Code Here

        assertThat(bField.size(), equalTo(2));
        assertThat(bField.get("type").toString(), equalTo("string"));
        assertThat(bField.get("index").toString(), equalTo("not_analyzed"));

        client().prepareIndex("my-index", "my-type", "1").setSource("a", "my tokens").setRefresh(true).get();
        CountResponse countResponse = client().prepareCount("my-index").setQuery(matchQuery("a.b", "my tokens")).get();
        assertThat(countResponse.getCount(), equalTo(1l));
    }
View Full Code Here

        assertThat(bField.size(), equalTo(2));
        assertThat(bField.get("type").toString(), equalTo("string"));
        assertThat(bField.get("index").toString(), equalTo("not_analyzed"));

        client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefresh(true).get();
        CountResponse countResponse = client().prepareCount("my-index").setQuery(matchQuery("a.b", "complete me")).get();
        assertThat(countResponse.getCount(), equalTo(1l));
    }
View Full Code Here

        assertThat(bField.size(), equalTo(2));
        assertThat(bField.get("type").toString(), equalTo("string"));
        assertThat(bField.get("index").toString(), equalTo("not_analyzed"));

        client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefresh(true).get();
        CountResponse countResponse = client().prepareCount("my-index").setQuery(matchQuery("a.b", "127.0.0.1")).get();
        assertThat(countResponse.getCount(), equalTo(1l));
    }
View Full Code Here

            // randomPreference should not start with '_' (reserved for known preference types (e.g. _shards, _primary)
            while (randomPreference.startsWith("_")) {
                randomPreference = randomUnicodeOfLengthBetween(0, 4);
            }
            // id is not indexed, but lets see that we automatically convert to
            CountResponse countResponse = client().prepareCount().setQuery(QueryBuilders.matchAllQuery()).setPreference(randomPreference).get();
            assertHitCount(countResponse, 6l);
        }
    }
View Full Code Here

                        .endObject().endObject().endObject())
                .execute().actionGet();

        client().prepareIndex("test", "type1", "1").setSource("from", "192.168.0.5", "to", "192.168.0.10").setRefresh(true).execute().actionGet();

        CountResponse countResponse = client().prepareCount()
                .setQuery(boolQuery().must(rangeQuery("from").lt("192.168.0.7")).must(rangeQuery("to").gt("192.168.0.7")))
                .execute().actionGet();

        assertHitCount(countResponse, 1l);
    }
View Full Code Here

    public void simpleIdTests() {
        createIndex("test");

        client().prepareIndex("test", "type", "XXX1").setSource("field", "value").setRefresh(true).execute().actionGet();
        // id is not indexed, but lets see that we automatically convert to
        CountResponse countResponse = client().prepareCount().setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet();
        assertHitCount(countResponse, 1l);

        countResponse = client().prepareCount().setQuery(QueryBuilders.queryString("_id:XXX1")).execute().actionGet();
        assertHitCount(countResponse, 1l);
View Full Code Here

        createIndex("test");
        client().prepareIndex("test", "type1", "1").setSource("field", "2010-01-05T02:00").execute().actionGet();
        client().prepareIndex("test", "type1", "2").setSource("field", "2010-01-06T02:00").execute().actionGet();
        ensureGreen();
        refresh();
        CountResponse countResponse = client().prepareCount("test").setQuery(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d")).execute().actionGet();
        assertHitCount(countResponse, 2l);

        countResponse = client().prepareCount("test").setQuery(QueryBuilders.queryString("field:[2010-01-03||+2d TO 2010-01-04||+2d]")).execute().actionGet();
        assertHitCount(countResponse, 2l);
    }
View Full Code Here

        String upperBound = "2010-01-" + String.valueOf(max+1) + "||+2d";
        String lowerBound = "2009-12-01||+2d";

        // sanity check
        CountResponse countResponse = client().prepareCount("test").setQuery(QueryBuilders.rangeQuery("field").gte(lowerBound).lte(upperBound)).execute().actionGet();
        assertHitCount(countResponse, max);

        // threshold <= actual count
        for (int i = 1; i <= max; i++) {
            countResponse = client().prepareCount("test").setQuery(QueryBuilders.rangeQuery("field").gte(lowerBound).lte(upperBound)).setTerminateAfter(i).execute().actionGet();
            assertHitCount(countResponse, i);
            assertTrue(countResponse.terminatedEarly());
        }

        // threshold > actual count
        countResponse = client().prepareCount("test").setQuery(QueryBuilders.rangeQuery("field").gte(lowerBound).lte(upperBound)).setTerminateAfter(max + randomIntBetween(1, max)).execute().actionGet();
        assertHitCount(countResponse, max);
        assertFalse(countResponse.terminatedEarly());
    }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.count.CountResponse

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.