use of org.elasticsearch.index.query.MatchAllQueryBuilder in project crate by crate.
the class PartitionedTableIntegrationTest method validateInsertPartitionedTable.
private void validateInsertPartitionedTable() {
Set<String> indexUUIDs = new HashSet<>(3);
String partitionName = new PartitionName("parted", Collections.singletonList(new BytesRef(String.valueOf(13959981214861L)))).asIndexName();
assertThat(internalCluster().clusterService().state().metaData().hasIndex(partitionName), is(true));
IndexMetaData indexMetaData = client().admin().cluster().prepareState().execute().actionGet().getState().metaData().indices().get(partitionName);
indexUUIDs.add(indexMetaData.getIndexUUID());
assertThat(indexMetaData.getAliases().get("parted"), notNullValue());
assertThat(client().prepareSearch(partitionName).setTypes(Constants.DEFAULT_MAPPING_TYPE).setSize(0).setQuery(new MatchAllQueryBuilder()).execute().actionGet().getHits().totalHits(), is(1L));
partitionName = new PartitionName("parted", Collections.singletonList(new BytesRef(String.valueOf(0L)))).asIndexName();
assertThat(internalCluster().clusterService().state().metaData().hasIndex(partitionName), is(true));
indexMetaData = client().admin().cluster().prepareState().execute().actionGet().getState().metaData().indices().get(partitionName);
indexUUIDs.add(indexMetaData.getIndexUUID());
assertThat(indexMetaData.getAliases().get("parted"), notNullValue());
assertThat(client().prepareSearch(partitionName).setTypes(Constants.DEFAULT_MAPPING_TYPE).setSize(0).setQuery(new MatchAllQueryBuilder()).execute().actionGet().getHits().totalHits(), is(1L));
List<BytesRef> nullList = new ArrayList<>();
nullList.add(null);
partitionName = new PartitionName("parted", nullList).asIndexName();
assertThat(internalCluster().clusterService().state().metaData().hasIndex(partitionName), is(true));
indexMetaData = client().admin().cluster().prepareState().execute().actionGet().getState().metaData().indices().get(partitionName);
indexUUIDs.add(indexMetaData.getIndexUUID());
assertThat(indexMetaData.getAliases().get("parted"), notNullValue());
assertThat(client().prepareSearch(partitionName).setTypes(Constants.DEFAULT_MAPPING_TYPE).setSize(0).setQuery(new MatchAllQueryBuilder()).execute().actionGet().getHits().totalHits(), is(1L));
assertThat(indexUUIDs.size(), is(3));
}
use of org.elasticsearch.index.query.MatchAllQueryBuilder in project incubator-sdap-mudrod by apache.
the class ESDriver method getDocCount.
public int getDocCount(String index, String... type) {
MatchAllQueryBuilder search = QueryBuilders.matchAllQuery();
String[] indexArr = new String[] { index };
return this.getDocCount(indexArr, type, search);
}
use of org.elasticsearch.index.query.MatchAllQueryBuilder in project presto by prestodb.
the class ElasticsearchQueryBuilder method buildSearchQuery.
public static QueryBuilder buildSearchQuery(ConnectorSession session, TupleDomain<ElasticsearchColumnHandle> constraint, Optional<String> query) {
BoolQueryBuilder queryBuilder = new BoolQueryBuilder();
if (constraint.getDomains().isPresent()) {
for (Map.Entry<ElasticsearchColumnHandle, Domain> entry : constraint.getDomains().get().entrySet()) {
ElasticsearchColumnHandle column = entry.getKey();
Domain domain = entry.getValue();
checkArgument(!domain.isNone(), "Unexpected NONE domain for %s", column.getName());
if (!domain.isAll()) {
queryBuilder.filter(new BoolQueryBuilder().must(buildPredicate(session, column.getName(), domain, column.getType())));
}
}
}
query.map(QueryStringQueryBuilder::new).ifPresent(queryBuilder::must);
if (queryBuilder.hasClauses()) {
return queryBuilder;
}
return new MatchAllQueryBuilder();
}
Aggregations