Java Code Examples for org.elasticsearch.client.core.CountRequest#source()
The following examples show how to use
org.elasticsearch.client.core.CountRequest#source() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractEs6_4ClientInstrumentationTest.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Test public void testCountRequest_validateSpanContentAndDbContext() throws Exception { createDocument(); reporter.reset(); CountRequest countRequest = new CountRequest(INDEX); SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder(); countSourceBuilder.query(QueryBuilders.termQuery(FOO, BAR)); countRequest.source(countSourceBuilder); CountResponse responses = doCount(countRequest); assertThat(responses.getCount()).isEqualTo(1); List<Span> spans = reporter.getSpans(); assertThat(spans).hasSize(1); Span span = spans.get(0); validateSpanContent(span, String.format("Elasticsearch: POST /%s/_count", INDEX), 200, "POST"); validateDbContextContent(span, "{\"query\":{\"term\":{\"foo\":{\"value\":\"bar\",\"boost\":1.0}}}}"); deleteDocument(); }
Example 2
Source File: EsRestClientContainer.java From frostmourne with MIT License | 5 votes |
public long totalCount(BoolQueryBuilder boolQueryBuilder, String[] indices) throws IOException { CountRequest countRequest = new CountRequest(indices); SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder(); countSourceBuilder.query(boolQueryBuilder); countRequest.source(countSourceBuilder); CountResponse countResponse = this.fetchHighLevelClient().count(countRequest, RequestOptions.DEFAULT); return countResponse.getCount(); }
Example 3
Source File: StatusMetricsBolt.java From storm-crawler with Apache License 2.0 | 5 votes |
@Override public void execute(Tuple input) { _collector.ack(input); // this bolt can be connected to anything // we just want to trigger a new search when the input is a tick tuple if (!TupleUtils.isTick(input)) { return; } for (StatusActionListener listener : listeners) { // still waiting for results from previous request if (!listener.isReady()) { LOG.debug("Not ready to get counts for status {}", listener.name); continue; } CountRequest request = new CountRequest(indexName); if (!listener.name.equalsIgnoreCase("TOTAL")) { SearchSourceBuilder sourceBuilder = new SearchSourceBuilder(); sourceBuilder.query(QueryBuilders.termQuery("status", listener.name)); request.source(sourceBuilder); } listener.busy(); connection.getClient().countAsync(request, RequestOptions.DEFAULT, listener); } }