本文整理汇总了Java中org.elasticsearch.action.count.CountResponse类的典型用法代码示例。如果您正苦于以下问题:Java CountResponse类的具体用法?Java CountResponse怎么用?Java CountResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CountResponse类属于org.elasticsearch.action.count包,在下文中一共展示了CountResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEsContent
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
protected void testEsContent(Client client) throws SQLException {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
CountResponse countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "user"))
.execute().actionGet();
Assert.assertEquals(11, countResponse.getCount());
countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "training"))
.execute().actionGet();
Assert.assertEquals(55, countResponse.getCount());
countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "exercise"))
.execute().actionGet();
Assert.assertEquals(275, countResponse.getCount());
}
示例2: testEsContent
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
protected void testEsContent(Client client) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
CountResponse countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "user"))
.execute().actionGet();
Assert.assertEquals(11, countResponse.getCount());
countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "training"))
.execute().actionGet();
Assert.assertEquals(55, countResponse.getCount());
countResponse = client.prepareCount(indexName).setQuery(QueryBuilders.termQuery("_type", "exercise"))
.execute().actionGet();
Assert.assertEquals(275, countResponse.getCount());
}
示例3: existSomeDocs
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
private void existSomeDocs(final String index, final String source, int timetoWaitInSec, final int expectedDocs)
throws InterruptedException {
assertThat("Documents exist",
awaitBusy(new Predicate<Object>() {
@Override
public boolean apply(Object o) {
QueryBuilder query;
if (source == null) {
query = QueryBuilders.matchAllQuery();
} else {
query = QueryBuilders.queryString(source).defaultField("id");
}
CountResponse response = client().prepareCount(index)
.setQuery(query).execute().actionGet();
System.out.println("FLORIAN: " + response.getCount());
return response.getCount() == expectedDocs;
}
}, timetoWaitInSec, TimeUnit.SECONDS), equalTo(true));
}
示例4: countRequest
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
/**
* With retry
*/
public static long countRequest(final String index, final QueryBuilder query, final String... types) {
CountResponse response = withRetry(new ElasticsearchWithRetry<CountResponse>() {
public CountResponse call(Client client) throws NoNodeAvailableException {
CountRequestBuilder request_builder = new CountRequestBuilder(client);
request_builder.setIndices(index);
request_builder.setTypes(types);
request_builder.setQuery(query);
return request_builder.execute().actionGet();
}
});
if (response == null) {
return 0;
}
return response.getCount();
}
示例5: count
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@Override
public ActionFuture<CountResponse> count(final CountRequest request) {
AdapterActionFuture<CountResponse, SearchResponse> actionFuture = new AdapterActionFuture<CountResponse, SearchResponse>() {
@Override
protected CountResponse convert(SearchResponse listenerResponse) {
return new CountResponse(listenerResponse);
}
};
deprecationLogger.deprecated("the count api is deprecated and will be removed from the java api in the next major version");
execute(SearchAction.INSTANCE, request.toSearchRequest(), actionFuture);
return actionFuture;
}
示例6: count
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
/**
*
* @return number of all Assets in the index.
*/
@Override
public long count() {
CountResponse countResponse = client.prepareCount(indexName)
.setQuery(termQuery("_type", documentType))
.execute()
.actionGet();
return countResponse.getCount();
}
示例7: getPendingDocuments
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@Override
public int getPendingDocuments() {
try {
CountResponse response = client.prepareCount(indexName)
.setQuery(filteredQuery(matchAllQuery(), orFilter(
missingFilter(SearchService.FIELD_INDEXED),
termFilter(SearchService.FIELD_INDEXED, false))))
.execute()
.actionGet();
return (int) response.getCount();
} catch (Exception e) {
getLog().error("Problem getting pending docs for index builder [" + getName() + "]", e);
}
return 0;
}
示例8: getNDocs
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@Override
public int getNDocs() {
assureIndex();
CountResponse response = client.prepareCount(indexName)
.setQuery(filteredQuery(matchAllQuery(),termFilter(SearchService.FIELD_INDEXED, true)))
.execute()
.actionGet();
return (int) response.getCount();
}
示例9: count
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
public long count(BaseQueryBuilder xqb) throws Exception {
CountResponse response =
esclient.client.prepareCount(index).
setQuery(xqb).
execute().actionGet();
return response.getCount();
}
示例10: infiniteTest
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
/**
* I use this test for a shell like experience, has to be cancelled manually.
*/
// @Test
public void infiniteTest() throws InterruptedException {
Thread.sleep(200); // allow river to start
while (true) {
Thread.sleep(200); // time for poller to index
refreshIndex();
CountResponse
resp =
node.client().count(countRequest(index).types(type).source(queryString("mowbray").defaultField("manager").toString())).actionGet();
logger.debug("How many moggas? {} !", resp.getCount());
}
}
示例11: waitForUpdateCompletion
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@SneakyThrows({InterruptedException.class})
protected void waitForUpdateCompletion(int inv) {
while(true){
CountRequestBuilder countRequestBuilder = client.prepareCount (dummyIndexName (getNUMROWS(), getNUMCOLS(), inv)).setTypes (getDocumentType ());
CountResponse countResponse = countRequestBuilder.execute ().actionGet ();
if(countResponse.getCount ()==getNUMROWS ())
break;
Thread.sleep (500);
}
}
示例12: waitForUpdateCompletion
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@SneakyThrows({InterruptedException.class})
protected void waitForUpdateCompletion() {
while(true){
CountRequestBuilder countRequestBuilder = client.prepareCount (adminHelper.dummyName (getNUMROWS(), getNUMCOLS())).setTypes (getDocumentType ());
CountResponse countResponse = countRequestBuilder.execute ().actionGet ();
if(countResponse.getCount ()==getNUMROWS ())
break;
Thread.sleep (500);
}
}
示例13: testDefaultArgument
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@Test
public void testDefaultArgument() throws IOException {
String index = "topic";
createDefaultESSink(index);
refresh();
CountResponse countResponse = client().count(new CountRequest(index)).actionGet();
assertEquals(countResponse.getCount(), 100);
}
示例14: count
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
@Override
public CountResponse count(String[] indices, String... types) {
CountRequestBuilder countRequestBuilder = esClient.getClient().prepareCount(indices);
if (types != null && types.length > 0) {
countRequestBuilder.setTypes(types);
}
countRequestBuilder.setQuery(this.queryBuilder);
return countRequestBuilder.execute().actionGet();
}
示例15: getDocumentCount
import org.elasticsearch.action.count.CountResponse; //导入依赖的package包/类
public long getDocumentCount() throws Exception {
try (Client client = getClient()) {
client.admin().indices().refresh(new RefreshRequest(INDEX_NAME)).actionGet();
ActionFuture<CountResponse> response = client.count(new CountRequest(INDEX_NAME).types(DOCUMENT_TYPE));
CountResponse countResponse = response.get();
return countResponse.getCount();
}
}