本文整理汇总了Java中org.elasticsearch.index.query.FilterBuilders.boolFilter方法的典型用法代码示例。如果您正苦于以下问题:Java FilterBuilders.boolFilter方法的具体用法?Java FilterBuilders.boolFilter怎么用?Java FilterBuilders.boolFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.index.query.FilterBuilders
的用法示例。
在下文中一共展示了FilterBuilders.boolFilter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeFilterBuilder
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的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: explanWhere
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的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);
}
}
}
示例3: createFrequentlyRelatedContentSearch
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public SearchSourceBuilder createFrequentlyRelatedContentSearch(RelatedItemSearch search) {
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
String id = search.getRelatedItemId();
BoolFilterBuilder b = FilterBuilders.boolFilter();
b.must(FilterBuilders.termFilter(relatedWithAttribute, id));
RelatedItemAdditionalProperties searchProps = search.getAdditionalSearchCriteria();
int numberOfProps = searchProps.getNumberOfProperties();
for(int i = 0;i<numberOfProps;i++) {
b.must(FilterBuilders.termFilter(searchProps.getPropertyName(i), searchProps.getPropertyValue(i)));
}
ConstantScoreQueryBuilder cs = QueryBuilders.constantScoreQuery(b);
TermsFacetBuilder facetBuilder = FacetBuilders.termsFacet(facetResultName).field(itemIdentifierAttribute).size(search.getMaxResults());
if(hasExecutionHint) {
facetBuilder.executionHint(executionHint);
}
sourceBuilder.size(0);
sourceBuilder.query(cs);
sourceBuilder.timeout(searchTimeoutValue);
sourceBuilder.facet(facetBuilder);
log.debug("Frequently Related Query Built: {}",sourceBuilder);
return sourceBuilder;
}
示例4: buildTopicIdFilter
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
public static FilterBuilder buildTopicIdFilter(
ImmutableList<ImmutableList<InclusionExclusionId>> topicIdSets
) {
ImmutableList.Builder<FilterBuilder> topicIdFilters = ImmutableList.builder();
for (List<InclusionExclusionId> idSet : topicIdSets) {
BoolFilterBuilder filterForThisSet = FilterBuilders.boolFilter();
for (InclusionExclusionId id : idSet) {
addFilterForTopicId(filterForThisSet, id);
}
topicIdFilters.add(filterForThisSet);
}
OrFilterBuilder orFilter = FilterBuilders.orFilter();
topicIdFilters.build().forEach(orFilter::add);
return orFilter;
}
示例5: createFilterBuilder
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
/**
* Create our filter builder. We need to restrict our results on edge search, as well as on types, and any filters
* that came from the grammar.
*/
private FilterBuilder createFilterBuilder( final SearchEdge searchEdge, final QueryVisitor visitor,
final SearchTypes searchTypes ) {
String context = createContextName( applicationScope, searchEdge );
// Add our filter for context to our query for fast execution.
// Fast because it utilizes bitsets internally. See this post for more detail.
// http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/
// TODO evaluate performance when it's an all query.
// Do we need to put the context term first for performance?
//make sure we have entity in the context
BoolFilterBuilder boolQueryFilter = FilterBuilders.boolFilter();
//add our edge search
boolQueryFilter.must( FilterBuilders.termFilter( IndexingUtils.EDGE_SEARCH_FIELDNAME, context ) );
/**
* For the types the user specified, add them to an OR so 1 of them must match
*/
final String[] sourceTypes = searchTypes.getTypeNames( applicationScope );
if ( sourceTypes.length > 0 ) {
final FilterBuilder[] typeTerms = new FilterBuilder[sourceTypes.length];
for ( int i = 0; i < sourceTypes.length; i++ ) {
typeTerms[i] = FilterBuilders.termFilter( IndexingUtils.ENTITY_TYPE_FIELDNAME, sourceTypes[i] );
}
//add all our types, 1 type must match per query
boolQueryFilter.must( FilterBuilders.orFilter( typeTerms ) );
}
//if we have a filter from our visitor, add it
Optional<FilterBuilder> queryBuilder = visitor.getFilterBuilder();
if ( queryBuilder.isPresent() ) {
boolQueryFilter.must( queryBuilder.get() );
}
return boolQueryFilter;
}
示例6: getAuditLog
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
@GET
@Path("/auditlog")
@Produces(MediaType.APPLICATION_JSON)
@AuditIgnore
public StreamingOutput getAuditLog(
@QueryParam("operation") String operation,
@QueryParam("path") String path,
@QueryParam("username") String username,
@QueryParam("usertype") String usertype,
@QueryParam("id") String id,
@QueryParam("from") Integer from,
@QueryParam("size") Integer size,
@QueryParam("sort") String sort) throws IOException {
BoolFilterBuilder filterBuilder = FilterBuilders.boolFilter();
boolean filterAdded = false;
if (StringUtils.isNotBlank(path)) {
filterAdded = true;
filterBuilder.must(FilterBuilders.prefixFilter("path", path));
}
if (StringUtils.isNotBlank(operation)) {
filterAdded = true;
filterBuilder.must(FilterBuilders.termFilter("operation", operation));
}
if (StringUtils.isNotBlank(username)) {
filterAdded = true;
filterBuilder.must(FilterBuilders.termFilter("username", username));
}
if (StringUtils.isNotBlank(usertype)) {
filterAdded = true;
filterBuilder.must(FilterBuilders.termFilter("usertype", usertype));
}
if (StringUtils.isNotBlank(id)) {
filterAdded = true;
filterBuilder.must(FilterBuilders.termFilter("id", id));
}
if (!filterAdded) {
filterBuilder = null;
}
try {
SearchResponse response = statsClientService.performSearch(StatsRecordType.AUDIT, filterBuilder, from, size, sort);
return new ESDataOnlyResponse(response);
} catch (SearchIndexMissingException e) {
return null;
}
}
示例7: fieldNameTerm
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
/**
* Generate the field name term for the field name for filters
*/
private NestedFilterBuilder fieldNameTerm( final String fieldName, final FilterBuilder fieldValueBuilder ) {
final BoolFilterBuilder booleanQuery = FilterBuilders.boolFilter();
booleanQuery.must( FilterBuilders.termFilter( IndexingUtils.FIELD_NAME_NESTED, fieldName ) );
booleanQuery.must( fieldValueBuilder );
return FilterBuilders.nestedFilter( IndexingUtils.ENTITY_FIELDS, booleanQuery );
}
示例8: explan
import org.elasticsearch.index.query.FilterBuilders; //导入方法依赖的package包/类
/**
* 将where条件构建成filter
*
* @param where
* @return
* @throws SqlParseException
*/
public static BoolFilterBuilder explan(Where where) throws SqlParseException {
BoolFilterBuilder boolFilter = FilterBuilders.boolFilter();
new FilterMaker().explanWhere(boolFilter, where);
return boolFilter;
}