Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountResponse


                client().prepareIndex("test", "type", "1").setSource("term", "1"),
                client().prepareIndex("test", "type", "2").setSource("term", "2"),
                client().prepareIndex("test", "type", "3").setSource("term", "3"),
                client().prepareIndex("test", "type", "4").setSource("term", "4"));

        CountResponse countResponse = client().prepareCount("test")
                .setQuery(filteredQuery(matchAllQuery(), termsLookupFilter("term").lookupIndex("lookup").lookupType("type").lookupId("1").lookupPath("terms"))).get();
        assertHitCount(countResponse, 2l);

        // same as above, just on the _id...
        countResponse = client().prepareCount("test")
View Full Code Here


        client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
        client().prepareIndex("test", "type2", "2").setSource("field1", "value2").get();
        refresh();

        CountResponse countResponse = client().prepareCount().setQuery(QueryBuilders.constantScoreQuery(FilterBuilders.idsFilter("type1", "type2").ids("1", "2"))).get();
        assertHitCount(countResponse, 2l);

        countResponse = client().prepareCount().setQuery(QueryBuilders.constantScoreQuery(FilterBuilders.idsFilter().ids("1", "2"))).get();
        assertHitCount(countResponse, 2l);
View Full Code Here

        client().prepareIndex("test", "type1", "1").setSource("field1", "value1").get();
        client().prepareIndex("test", "type2", "2").setSource("field1", "value2").get();
        refresh();

        CountResponse countResponse = client().prepareCount().setQuery(QueryBuilders.idsQuery("type1", "type2").ids("1", "2")).get();
        assertHitCount(countResponse, 2l);

        countResponse = client().prepareCount().setQuery(QueryBuilders.idsQuery().ids("1")).get();
        assertHitCount(countResponse, 1l);
View Full Code Here

        client().prepareIndex("test", "type1", "17").setSource("num_byte", 17, "num_short", 17, "num_integer", 17,
                "num_long", 17, "num_float", 17, "num_double", 17).get();
        refresh();

        CountResponse countResponse;
        logger.info("--> term query on 1");
        countResponse = client().prepareCount("test").setQuery(termQuery("num_byte", 1)).get();
        assertHitCount(countResponse, 1l);
        countResponse = client().prepareCount("test").setQuery(termQuery("num_short", 1)).get();
        assertHitCount(countResponse, 1l);
View Full Code Here

        client().prepareIndex("test", "test", "2").setSource("description", "foo other anything").get();
        client().prepareIndex("test", "test", "3").setSource("description", "foo other").get();
        client().prepareIndex("test", "test", "4").setSource("description", "foo").get();
        refresh();

        CountResponse response = client().prepareCount("test")
                .setQuery(QueryBuilders.spanOrQuery().clause(QueryBuilders.spanTermQuery("description", "bar"))).get();
        assertHitCount(response, 1l);
        response = client().prepareCount("test")
                .setQuery(QueryBuilders.spanOrQuery().clause(QueryBuilders.spanTermQuery("test.description", "bar"))).get();
        assertHitCount(response, 1l);
View Full Code Here

            }
        }

        refresh();

        CountResponse countResponse = client().prepareCount().get();
        assertHitCount(countResponse, numDocs);
    }
View Full Code Here

                            .setQuery(query).execute().actionGet();

                    logger.debug("result {}", response.toString());
                    totalHits = response.getHits().getTotalHits();
                } else {
                    CountResponse response = client().prepareCount(indexName)
                            .setTypes(FsRiverUtil.INDEX_TYPE_DOC)
                            .setQuery(query).execute().actionGet();
                    totalHits = response.getCount();
                }

                if (expected == null) {
                    return (totalHits >= 1);
                } else {
View Full Code Here

    @Test
    public void test_multiple_rivers() throws Exception {
        startRiver(getRiverName() + "_1", endRiverDefinition(startRiverDefinition("testfs1")));
        startRiver(getRiverName() + "_2", endRiverDefinition(startRiverDefinition("testfs2")));
        CountResponse response = client().prepareCount(getRiverName() + "_1", getRiverName() + "_2")
                .setTypes(FsRiverUtil.INDEX_TYPE_DOC)
                .setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
        assertThat("We should have two docs...", response.getCount(), equalTo(2L));
    }
View Full Code Here

    }

    @Test
    public void test_filename_analyzer() throws Exception {
        startRiver(getRiverName(), endRiverDefinition(startRiverDefinition("testfs1")));
        CountResponse response = client().prepareCount(getRiverName())
                .setTypes(FsRiverUtil.INDEX_TYPE_DOC)
                .setQuery(QueryBuilders.termQuery("file.filename", "roottxtfile.txt")).execute().actionGet();
        assertThat("We should have one doc...", response.getCount(), equalTo(1L));
    }
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.