Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountResponse


            logger.info("WriteResult: {}", result.toString());
            refreshIndex(index1);

            ActionFuture<IndicesExistsResponse> response = getNode().client().admin().indices().exists(new IndicesExistsRequest(index1));
            assertThat(response.actionGet().isExists(), equalTo(true));
            CountResponse countResponse = getNode().client().count(countRequest(index1)).actionGet();
            logger.info("Document count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(0l));
            mongoDB.getCollection(collection1).remove(dbObject);

            mongoDocument = copyToStringFromClasspath(TEST_SIMPLE_MONGODB_DOCUMENT_JSON);
            dbObject = (DBObject) JSON.parse(mongoDocument);
            result = mongoDB.getCollection(collection2).insert(dbObject);
            Thread.sleep(wait);
            String id = dbObject.get("_id").toString();
            logger.info("WriteResult: {}", result.toString());
            refreshIndex(index2);

            response = getNode().client().admin().indices().exists(new IndicesExistsRequest(index2));
            assertThat(response.actionGet().isExists(), equalTo(true));

            SearchResponse sr = getNode().client().prepareSearch(index2).setQuery(QueryBuilders.queryString(id).defaultField("_id")).execute().actionGet();
            logger.debug("SearchResponse {}", sr.toString());
            long totalHits = sr.getHits().getTotalHits();
            logger.debug("TotalHits: {}", totalHits);
            assertThat(totalHits, equalTo(1l));

            dbObject.put("to_be_deleted", Boolean.TRUE);
            mongoDB.getCollection(collection2).save(dbObject);

            Thread.sleep(wait);
            refreshIndex(index2);

            countResponse = getNode().client().count(countRequest(index2)).actionGet();
            logger.info("Document count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(0l));

            mongoDB.getCollection(collection2).remove(dbObject);
        } catch (Throwable t) {
            logger.error("testTwoRiversGroovyScript failed.", t);
            t.printStackTrace();
View Full Code Here


            logger.info("WriteResult: {}", result.toString());
            refreshIndex(index);

            ActionFuture<IndicesExistsResponse> response = getNode().client().admin().indices().exists(new IndicesExistsRequest(index));
            assertThat(response.actionGet().isExists(), equalTo(true));
            CountResponse countResponse = getNode().client().count(countRequest(index)).actionGet();
            logger.info("Document count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(2l));

            mongoCollection.remove(dbObject);

        } catch (Throwable t) {
            logger.error("testSimpleTransformationScript failed.", t);
View Full Code Here

            Thread.sleep(wait);
            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(getIndex())).actionGet().isExists(),
                    equalTo(true));
            assertThat(getNode().client().admin().indices().prepareTypesExists(getIndex()).setTypes(getDatabase()).execute().actionGet()
                    .isExists(), equalTo(true));
            CountResponse countResponse = getNode().client().prepareCount(getIndex())
                    .setQuery(QueryBuilders.queryString(value).defaultField("attribute1")).get();
            assertThat(countResponse.getCount(), equalTo(1L));
        } catch (Throwable t) {
            logger.error("testDropCollectionIssue79 failed.", t);
            t.printStackTrace();
            throw t;
        } finally {
View Full Code Here

            Thread.sleep(wait);
            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(getIndex())).actionGet().isExists(),
                    equalTo(true));
            assertThat(getNode().client().admin().indices().prepareTypesExists(getIndex()).setTypes(getDatabase()).execute().actionGet()
                    .isExists(), equalTo(true));
            CountResponse countResponse = getNode().client().prepareCount(getIndex())
                    .setQuery(QueryBuilders.queryString(value).defaultField("attribute1")).get();
            assertThat(countResponse.getCount(), equalTo(1L));
        } catch (Throwable t) {
            logger.error("testDropDatabaseIssue133 failed.", t);
            t.printStackTrace();
            throw t;
        } finally {
View Full Code Here

            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());
            ids.add(id);
        }

        CountResponse countResponse;

        while (true) {
            Thread.sleep(wait);
            refreshIndex();
            countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
            logger.debug("Index total count: {}", countResponse.getCount());
            if (countResponse.getCount() == count) {
                break;
            }
        }

        countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
        logger.debug("Index total count: {}", countResponse.getCount());
        assertThat(countResponse.getCount(), equalTo(count));

        SearchResponse response = getNode().client().prepareSearch(getIndex())
                .setQuery(QueryBuilders.queryString(attachment.getCriteria())).execute().actionGet();
        long totalHits = response.getHits().getTotalHits();
        logger.debug("TotalHits: {}", totalHits);
        assertThat(totalHits, equalTo(count));

        for (String id : ids) {
            gridFS.remove(new ObjectId(id));
        }

        Thread.sleep(wait);
        refreshIndex();

        countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
        logger.debug("Count after delete request: {}", countResponse.getCount());
        assertThat(countResponse.getCount(), equalTo(0L));
    }
View Full Code Here

            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));

            refreshIndex(index);

            CountResponse countResponse = getNode().client().count(countRequest(index)).actionGet();
            assertThat(countResponse.getCount(), equalTo(0L));

            mongoCollection.remove(dbObject);

            // Wait 5 seconds and store a new document
            Thread.sleep(5000);

            dbObject = (DBObject) JSON.parse(mongoDocument);
            mongoCollection.insert(dbObject);
            Thread.sleep(wait);

            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));
            assertThat(getNode().client().admin().indices().prepareTypesExists(index).setTypes(getDatabase()).execute().actionGet()
                    .isExists(), equalTo(true));

            refreshIndex(index);

            countResponse = getNode().client().count(countRequest(index)).actionGet();
            assertThat(countResponse.getCount(), equalTo(1L));

            mongoCollection.remove(dbObject);
        } catch (Throwable t) {
            logger.error("testInitialTimestampInGroovy failed.", t);
            t.printStackTrace();
View Full Code Here

            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));

            refreshIndex(index);

            CountResponse countResponse = getNode().client().count(countRequest(index)).actionGet();
            assertThat(countResponse.getCount(), equalTo(0L));

            mongoCollection.remove(dbObject);

            // Wait 5 seconds and store a new document
            Thread.sleep(5000);

            dbObject = (DBObject) JSON.parse(mongoDocument);
            mongoCollection.insert(dbObject);
            Thread.sleep(wait);

            assertThat(getNode().client().admin().indices().exists(new IndicesExistsRequest(index)).actionGet().isExists(), equalTo(true));
            assertThat(getNode().client().admin().indices().prepareTypesExists(index).setTypes(getDatabase()).execute().actionGet()
                    .isExists(), equalTo(true));

            refreshIndex(index);

            countResponse = getNode().client().count(countRequest(index)).actionGet();
            assertThat(countResponse.getCount(), equalTo(1L));

            mongoCollection.remove(dbObject);
        } catch (Throwable t) {
            logger.error("testInitialTimestampInJavascript failed.", t);
            t.printStackTrace();
View Full Code Here

            createRiver();
            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
            logger.debug("Index total count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(1l));

            GetResponse getResponse = getNode().client().get(getRequest(getIndex()).id(id)).get();
            logger.debug("Get request for id {}: {}", id, getResponse.isExists());
            assertThat(getResponse.isExists(), equalTo(true));

            SearchResponse response = getNode().client().prepareSearch(getIndex()).setQuery(QueryBuilders.queryString("Aliquam")).execute()
                    .actionGet();
            logger.debug("SearchResponse {}", response.toString());
            long totalHits = response.getHits().getTotalHits();
            logger.debug("TotalHits: {}", totalHits);
            assertThat(totalHits, equalTo(1l));

            in = gridFS.createFile(content);
            in.setFilename("test-attachment-2.html");
            in.setContentType("text/html");
            in.save();
            in.validate();

            id = in.getId().toString();

            out = gridFS.findOne(in.getFilename());
            logger.debug("GridFS from findOne: {}", out);
            out = gridFS.findOne(new ObjectId(id));
            logger.debug("GridFS from findOne: {}", out);
            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
            logger.debug("Index total count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(2l));

            getResponse = getNode().client().get(getRequest(getIndex()).id(id)).get();
            logger.debug("Get request for id {}: {}", id, getResponse.isExists());
            assertThat(getResponse.isExists(), equalTo(true));
View Full Code Here

            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
            logger.debug("Index total count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(1l));

            GetResponse getResponse = getNode().client().get(getRequest(getIndex()).id(id)).get();
            logger.debug("Get request for id {}: {}", id, getResponse.isExists());
            assertThat(getResponse.isExists(), equalTo(true));
//            countResponse = getNode().client().count(countRequest(getIndex()).query(fieldQuery("_id", id))).actionGet();
View Full Code Here

            Assert.assertEquals(out.getId(), in.getId());

            Thread.sleep(wait);
            refreshIndex();

            CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();
            logger.debug("Index total count: {}", countResponse.getCount());
            assertThat(countResponse.getCount(), equalTo(1l));

            GetResponse getResponse = getNode().client().get(getRequest(getIndex()).id(id)).get();
            logger.debug("Get request for id {}: {}", id, getResponse.isExists());
            assertThat(getResponse.isExists(), equalTo(true));
//            countResponse = getNode().client().count(countRequest(getIndex()).query(fieldQuery("_id", id))).actionGet();
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.