當前位置: 首頁>>代碼示例>>Java>>正文


Java CountResponse類代碼示例

本文整理匯總了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());
}
 
開發者ID:presidentio,項目名稱:test-data-generator,代碼行數:19,代碼來源:EsFileTest.java

示例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());
}
 
開發者ID:presidentio,項目名稱:test-data-generator,代碼行數:19,代碼來源:EsDirectTest.java

示例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));
}
 
開發者ID:frosenberg,項目名稱:elasticsearch-nvd-river,代碼行數:21,代碼來源:NvdRiverIntegrationTest.java

示例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();
}
 
開發者ID:hdsdi3g,項目名稱:MyDMAM,代碼行數:19,代碼來源:Elasticsearch.java

示例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;
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,代碼來源:AbstractClient.java

示例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();
}
 
開發者ID:aweisser,項目名稱:tdd-dojos.dojo1,代碼行數:14,代碼來源:EsAssetSearchIndex.java

示例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;
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:16,代碼來源:BaseElasticSearchIndexBuilder.java

示例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();
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:10,代碼來源:BaseElasticSearchIndexBuilder.java

示例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();
}
 
開發者ID:DemandCube,項目名稱:NeverwinterDP-Commons,代碼行數:8,代碼來源:ESObjectClient.java

示例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());
    }
}
 
開發者ID:sksamuel,項目名稱:elasticsearch-river-neo4j,代碼行數:16,代碼來源:Neo4jRiverIntTest.java

示例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);
  }
}
 
開發者ID:dfci-cccb,項目名稱:mev,代碼行數:11,代碼來源:PerfTestNumerify_AllTypes_Base.java

示例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);
  }
}
 
開發者ID:dfci-cccb,項目名稱:mev,代碼行數:11,代碼來源:PerfTestNumerify_Touch_Base.java

示例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);
}
 
開發者ID:Netflix,項目名稱:suro,代碼行數:11,代碼來源:TestElasticSearchSink.java

示例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();
}
 
開發者ID:alien4cloud,項目名稱:elasticsearch-mapping-parent,代碼行數:10,代碼來源:QueryHelper.java

示例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();
    }
}
 
開發者ID:datacleaner,項目名稱:extension_elasticsearch,代碼行數:10,代碼來源:ElasticSearchTestServer.java


注:本文中的org.elasticsearch.action.count.CountResponse類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。