本文整理汇总了Java中org.elasticsearch.index.query.BoolFilterBuilder类的典型用法代码示例。如果您正苦于以下问题:Java BoolFilterBuilder类的具体用法?Java BoolFilterBuilder怎么用?Java BoolFilterBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoolFilterBuilder类属于org.elasticsearch.index.query包,在下文中一共展示了BoolFilterBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeFilterBuilder
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
/**
* 获取过滤器
*
* @return
*/
public BoolFilterBuilder makeFilterBuilder(SearchRequestBuilder srb) {
// 过滤器
BoolFilterBuilder boolFilterBuilder = FilterBuilders.boolFilter();
if (request.getSafeFilterScript().size() > 0) {
ScriptFilterBuilder filter;
for (EsFilterScript filterScript : request.getSafeFilterScript()) {
filter = FilterBuilders.scriptFilter(filterScript.getScript());
if (filterScript.getScriptParams() != null
&& filterScript.getScriptParams().size() > 0) {
filter.params(filterScript.getScriptParams());
}
boolFilterBuilder.should(filter);
}
srb.setPostFilter(boolFilterBuilder);
}
return boolFilterBuilder;
}
示例2: addFilters
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
protected void addFilters(BoolFilterBuilder boolFilter) {
Map<String, Filter> filters = query.getFilters();
if (filters != null) {
for (Filter filter : filters.values()) {
FilterBuilder filterBuilder = converterFilter(filter);
if (filterBuilder != null) {
switch (filter.getClause()) {
case SHOULD:
boolFilter.should(filterBuilder);
break;
case MUST_NOT:
boolFilter.mustNot(filterBuilder);
break;
case MUST:
default:
boolFilter.must(filterBuilder);
}
}
}
}
}
示例3: addFilterForTopicId
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
private static void addFilterForTopicId(
BoolFilterBuilder filterBuilder,
InclusionExclusionId id
) {
NestedFilterBuilder filterForId = FilterBuilders.nestedFilter(
EsContent.TOPICS + "." + EsTopic.TYPE_NAME,
FilterBuilders.termFilter(
EsContent.TOPICS + "." + EsTopic.TYPE_NAME + "." + EsContent.ID,
id.getId()
)
);
if (id.isExcluded()) {
filterBuilder.mustNot(filterForId);
} else {
filterBuilder.must(filterForId);
}
}
示例4: explanWhere
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
private void explanWhere(BoolFilterBuilder boolFilter, Where where) throws SqlParseException {
while (where.getWheres().size() == 1) {
where = where.getWheres().getFirst();
}
if (where instanceof Condition) {
addSubFilter(boolFilter, where, (BaseFilterBuilder) make((Condition) where));
} else {
BoolFilterBuilder subFilter = FilterBuilders.boolFilter();
addSubFilter(boolFilter, where, subFilter);
for (Where subWhere : where.getWheres()) {
explanWhere(subFilter, subWhere);
}
}
}
示例5: addSubFilter
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
/**
* 增加嵌套插
*
* @param boolFilter
* @param where
* @param subFilter
*/
private void addSubFilter(BoolFilterBuilder boolFilter, Where where, BaseFilterBuilder subFilter) {
if (where.getConn() == CONN.AND) {
boolFilter.must(subFilter);
} else {
boolFilter.should(subFilter);
}
}
示例6: setWhere
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
/**
* Create filters based on
* the Where clause.
* @param where the 'WHERE' part of the SQL query.
* @throws SqlParseException
*/
private void setWhere(Where where) throws SqlParseException {
if (where != null) {
BoolFilterBuilder boolFilter = FilterMaker.explan(where);
request.setQuery(QueryBuilders.filteredQuery(null, boolFilter));
}
}
示例7: setWhere
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
/**
* Create filters or queries based on
* the Where clause.
* @param where the 'WHERE' part of the SQL query.
* @throws SqlParseException
*/
private void setWhere(Where where) throws SqlParseException {
if (where != null) {
if (select.isQuery) {
BoolQueryBuilder boolQuery = QueryMaker.explan(where);
request.setQuery(boolQuery);
} else {
BoolFilterBuilder boolFilter = FilterMaker.explan(where);
request.setQuery(QueryBuilders.filteredQuery(null, boolFilter));
}
}
}
示例8: setWhere
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
/**
* Create filters based on
* the Where clause.
*
* @param where the 'WHERE' part of the SQL query.
* @throws SqlParseException
*/
private void setWhere(Where where) throws SqlParseException {
if (where != null) {
BoolFilterBuilder boolFilter = FilterMaker.explan(where);
request.setQuery(QueryBuilders.filteredQuery(null, boolFilter));
} else {
request.setQuery(QueryBuilders.matchAllQuery());
}
}
示例9: addQ
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
protected void addQ(SearchRequestBuilder builder, BoolFilterBuilder boolFilter) {
if (types.length > 0) {
builder.setTypes(types);
}
if (query.getQ() != null && !query.getQ().isEmpty()) {
boolFilter.must(queryFilter(queryString(query.getQ()).defaultOperator(Operator.AND)));
}
}
示例10: addBbox
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
protected void addBbox(BoolFilterBuilder boolFilter) {
Envelope bbox = query.getBbox();
String geoField = query.getGeoField();
if ((geoField != null && !geoField.isEmpty()) && (bbox != null)) {
boolFilter.must(geoBoundingBoxFilter(geoField).bottomLeft(bbox.getMinY(), bbox.getMinX()).topRight(bbox.getMaxY(), bbox.getMaxX()));
}
}
示例11: searchRequest
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
@Override
public SearchRequestBuilder searchRequest() {
SearchRequestBuilder builder = client.prepareSearch(indices);
builder.setSearchType(SearchType.DEFAULT);
BoolFilterBuilder boolFilter = boolFilter();
addPaging(builder);
addQ(builder, boolFilter);
addFilters(boolFilter);
addBbox(boolFilter);
setFilter(builder, boolFilter);
addAggregations(builder);
addSorts(builder);
addFields(builder);
return builder;
}
示例12: deleteRequest
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
@Override
public DeleteByQueryRequestBuilder deleteRequest() {
DeleteByQueryRequestBuilder builder = client.prepareDeleteByQuery(indices);
BoolFilterBuilder boolFilter = boolFilter();
addQ(builder, boolFilter);
addFilters(boolFilter);
addBbox(boolFilter);
setFilter(builder, boolFilter);
return builder;
}
示例13: aclFilter
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
public FilterBuilder aclFilter(Map<String, Repository> repoMap) {
if (repoMap.isEmpty()) {
return boolFilter().mustNot(matchAllFilter());
}
// Compute cryptographic hash of repository set to use for cache key
String[] projectRepoPairs = repoMap.keySet().toArray(new String[repoMap.size()]);
Arrays.sort(projectRepoPairs);
String filterHash;
try {
MessageDigest hasher = MessageDigest.getInstance("SHA-256");
for (String pair : projectRepoPairs) {
hasher.update(pair.getBytes());
hasher.update((byte) 0);
}
filterHash = new String(Base64.encodeBase64(hasher.digest()));
} catch (Exception e) {
filterHash = null;
log.error("Caught exception generating ACL hash -- caching is disabled.", e);
}
// Create disjunction of individual repo ACL filters
BoolFilterBuilder filter = boolFilter();
if (filterHash != null) {
filter.cache(true)
.cacheKey("CACHE^ACLORFILTER^" + filterHash);
} else {
filter.cache(false);
}
for (Repository repo : repoMap.values()) {
filter.should(projectRepositoryFilter(repo.getProject().getKey(), repo.getSlug()));
}
return filter;
}
示例14: projectFilter
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
public FilterBuilder projectFilter(Iterable<String> projects) {
boolean filterAdded = false;
BoolFilterBuilder filter = boolFilter();
for (String project : projects) {
project = project.trim();
if (project.isEmpty()) {
continue;
}
filter.should(termFilter("project", project)
.cache(true)
.cacheKey("CACHE^PROJECTFILTER^" + project));
filterAdded = true;
}
return filterAdded ? filter : matchAllFilter();
}
示例15: repositoryFilter
import org.elasticsearch.index.query.BoolFilterBuilder; //导入依赖的package包/类
public FilterBuilder repositoryFilter(Iterable<String> repositories) {
boolean filterAdded = false;
BoolFilterBuilder filter = boolFilter();
for (String repository : repositories) {
repository = repository.trim();
if (repository.isEmpty()) {
continue;
}
filter.should(termFilter("repository", repository)
.cache(true)
.cacheKey("CACHE^REPOFILTER^" + repository));
filterAdded = true;
}
return filterAdded ? filter : matchAllFilter();
}