Java 类org.elasticsearch.index.query.TermsFilterBuilder 实例源码

项目:dcp-api    文件:StatsClientService.java   
/**
 * Check if some statistics record exists for specified conditions.
 * 
 * @param type of record we are looking for
 * @param conditions for lookup. Key is a name of field to filter over, Value is a value to filter for using term
 *          condition.
 * @return true if at least one record matching conditions exits
 */
public boolean checkStatisticsRecordExists(StatsRecordType type, Map<String, Object> conditions) {
    if (!statsConfiguration.enabled()) {
        return false;
    }
    SearchRequestBuilder srb = new SearchRequestBuilder(client);
    srb.setIndices(type.getSearchIndexName());
    srb.setTypes(type.getSearchIndexType());
    AndFilterBuilder fb = new AndFilterBuilder();
    fb.add(new TermsFilterBuilder(FIELD_TYPE, type.getSearchIndexedValue()));
    if (conditions != null) {
        for (String fieldName : conditions.keySet()) {
            fb.add(new TermsFilterBuilder(fieldName, conditions.get(fieldName)));
        }
    }

    srb.setQuery(new FilteredQueryBuilder(QueryBuilders.matchAllQuery(), fb));
    srb.addField("_id");

    try {
        SearchResponse searchResponse = srb.execute().actionGet();

        return searchResponse.getHits().getTotalHits() > 0;
    } catch (org.elasticsearch.indices.IndexMissingException e) {
        return false;
    }
}
项目:searchisko    文件:StatsClientService.java   
/**
 * Check if some statistics record exists for specified conditions.
 *
 * @param type       of record we are looking for
 * @param conditions for lookup. Key is a name of field to filter over, Value is a value to filter for using term
 *                   condition.
 * @return true if at least one record matching conditions exits
 */
public boolean checkStatisticsRecordExists(StatsRecordType type, Map<String, Object> conditions) {
    if (!statsConfiguration.enabled()) {
        return false;
    }
    SearchRequestBuilder srb = new SearchRequestBuilder(client);
    srb.setIndices(type.getSearchIndexName());
    srb.setTypes(type.getSearchIndexType());
    AndFilterBuilder fb = new AndFilterBuilder();
    fb.add(new TermsFilterBuilder(FIELD_TYPE, type.getSearchIndexedValue()));
    if (conditions != null) {
        for (String fieldName : conditions.keySet()) {
            fb.add(new TermsFilterBuilder(fieldName, conditions.get(fieldName)));
        }
    }

    srb.setQuery(new FilteredQueryBuilder(QueryBuilders.matchAllQuery(), fb));
    srb.addField("_id");

    try {
        SearchResponse searchResponse = srb.execute().actionGet();

        return searchResponse.getHits().getTotalHits() > 0;
    } catch (org.elasticsearch.indices.IndexMissingException e) {
        return false;
    }
}
项目:atlas-deer    文件:FiltersBuilder.java   
public static TermsFilterBuilder buildForSpecializations(
        Iterable<Specialization> specializations
) {
    return FilterBuilders.termsFilter(
            EsContent.SPECIALIZATION,
            Iterables.transform(specializations, Enum::name)
    );
}
项目:dcp-api    文件:SearchService.java   
private void addFilter(Map<String, FilterBuilder> searchFilters, String filterField, List<String> filterValue) {
    if (filterValue != null && !filterValue.isEmpty()) {
        searchFilters.put(filterField, new TermsFilterBuilder(filterField, filterValue));
    }
}
项目:dcp-api    文件:SearchService.java   
private void addFilter(Map<String, FilterBuilder> searchFilters, String filterField, String filterValue) {
    if (filterValue != null && !filterValue.isEmpty()) {
        searchFilters.put(filterField, new TermsFilterBuilder(filterField, filterValue));
    }
}
项目:dcp-api    文件:RenormalizeByEsValueTask.java   
@Override
protected void addFilters(SearchRequestBuilder srb) {
    srb.setFilter(new TermsFilterBuilder(esField, esValues));
}
项目:searchisko    文件:RenormalizeByEsValueTask.java   
@Override
protected void addFilters(SearchRequestBuilder srb) {
    srb.setPostFilter(new TermsFilterBuilder(esField, esValues));
}
项目:atlas-deer    文件:FiltersBuilder.java   
public static TermsFilterBuilder buildForPublishers(
        String field,
        Iterable<Publisher> publishers
) {
    return FilterBuilders.termsFilter(field, Iterables.transform(publishers, Publisher.TO_KEY));
}