本文整理汇总了Java中org.hibernate.search.query.dsl.BooleanJunction.createQuery方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanJunction.createQuery方法的具体用法?Java BooleanJunction.createQuery怎么用?Java BooleanJunction.createQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.search.query.dsl.BooleanJunction
的用法示例。
在下文中一共展示了BooleanJunction.createQuery方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: all
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
public Query all(Collection<Query> subQueries) {
BooleanJunction<BooleanJunction> bool = queryBuilder.bool();
for (Query subQuery : subQueries) {
bool.must(subQuery);
}
return bool.createQuery();
}
示例2: any
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
public Query any(Collection<Query> subQueries) {
BooleanJunction<BooleanJunction> bool = queryBuilder.bool();
for (Query subQuery : subQueries) {
bool.should(subQuery);
}
return bool.createQuery();
}
示例3: in
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
public Query in(String fieldName, Collection<?> values) {
BooleanJunction<BooleanJunction> bool = queryBuilder.bool();
for (Object value : values) {
bool.should(equal(fieldName, value));
}
return bool.createQuery();
}
示例4: all
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
public Query all(QueryBuilder builder, Query ... queries) {
BooleanJunction<?> junction = null;
for (Query query : queries) {
if (query != null) {
junction = junction != null ? junction : builder.bool();
junction.must(query);
}
}
return junction != null ? junction.createQuery() : null;
}
示例5: any
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
public Query any(QueryBuilder builder, Query ... queries) {
BooleanJunction<?> junction = null;
for (Query query : queries) {
if (query != null) {
junction = junction != null ? junction : builder.bool();
junction.should(query);
}
}
return junction != null ? junction.createQuery() : null;
}
示例6: matchOneIfGiven
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
public <P> Query matchOneIfGiven(QueryBuilder builder, String fieldPath, Collection<? extends P> possibleValues) {
if (possibleValues == null || possibleValues.isEmpty()) {
return null;
}
BooleanJunction<?> subJunction = builder.bool();
for (P possibleValue : possibleValues) {
subJunction.should(builder.keyword()
.onField(fieldPath)
.matching(possibleValue)
.createQuery());
}
return subJunction.createQuery();
}
示例7: matchAllIfGiven
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
public <P> Query matchAllIfGiven(QueryBuilder builder, String fieldPath, Collection<? extends P> values) {
if (values == null || values.isEmpty()) {
return null;
}
BooleanJunction<?> subJunction = builder.bool();
for (P possibleValue : values) {
subJunction.must(builder.keyword()
.onField(fieldPath)
.matching(possibleValue)
.createQuery());
}
return subJunction.createQuery();
}
示例8: performSearch
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private static List<Object> performSearch(Condition where, String cacheName, ObjectConnection connection)
throws TranslatorException {
LogManager.logTrace(LogConstants.CTX_CONNECTOR,
"Using Lucene Searching."); //$NON-NLS-1$
Class<?> type = connection.getType(cacheName);
//Map<?, ?> cache,
SearchManager searchManager = Search
.getSearchManager((Cache<?, ?>) connection.getCacheContainer().getCache(cacheName) );
QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClass(type).get();
BooleanJunction<BooleanJunction> junction = queryBuilder.bool();
boolean createdQueries = buildQueryFromWhereClause(where,
junction, queryBuilder);
Query query = null;
if (createdQueries) {
query = junction.createQuery();
} else {
query = queryBuilder.all().createQuery();
}
CacheQuery cacheQuery = searchManager.getQuery(query, type); // rootNodeType
List<Object> results = cacheQuery.list();
if (results == null || results.isEmpty()) {
return Collections.emptyList();
}
return results;
}
示例9: createQuery
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private Query createQuery(QueryBuilder builder, BooleanJunction<?> context, boolean valid) {
try {
if (valid) {
return context.createQuery();
} else {
return builder.all().except(builder.all().createQuery()).createQuery();
}
} catch (Exception e) {
throw propagate(e);
}
}
示例10: buildQuery
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private Query buildQuery(String q, Member homeMember, StandingState standingState, boolean standingStateNot) {
QueryBuilder queryBuilder = getSearchFactory().buildQueryBuilder()
.forEntity(Affiliate.class).get();
//Odd issue with Camel case text not finding exact matches. Workaround using lowercase.
Query textQuery = buildWildcardQueryForTokens(queryBuilder, q.toLowerCase());
if (homeMember == null && standingState == null) {
return textQuery;
} else {
BooleanJunction <MustJunction> building = queryBuilder
.bool()
.must(textQuery);
if (homeMember != null) {
Query homeMemberQuery = buildQueryMatchingHomeMember(queryBuilder, homeMember);
building = building.must(homeMemberQuery);
}
if (standingState != null) {
Query standingStateQuery = buildQueryMatchingStandingState(queryBuilder, standingState);
MustJunction standingStateBuilding = building.must(standingStateQuery);
if (standingStateNot) {
// Caught up in .not() returning boolean rather than must...
building = standingStateBuilding.not();
} else {
building = standingStateBuilding;
}
}
return building.createQuery();
}
}
示例11: buildWildcardQueryForTokens
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
Query buildWildcardQueryForTokens(QueryBuilder queryBuilder, String q) {
BooleanJunction<?> bool = queryBuilder.bool();
//Analyzer searchtokenAnalyzer = getSearchFactory().getAnalyzer("searchtokenanalyzer");
try {
// We're letting the default analyzer tokenize the main query for the ALL field
Query allKeywordQuery = queryBuilder.keyword()
.onField(FIELD_ALL).ignoreFieldBridge().matching(q)
.createQuery();
bool.should(allKeywordQuery);
} catch (EmptyQueryException e) {
// ignore it, and allow the full query since we have a limit.
}
// And then we do a dumb split on whitespace and turn every string into a wildcard query
// on all the fields.
String[] tokens = q.split("\\s+");
for (String token : tokens) {
bool.should(queryBuilder.keyword()
.wildcard()
.onField(FIELD_ALL).ignoreFieldBridge().matching(token+"*")
.createQuery());
bool.should(queryBuilder.keyword()
.wildcard()
.onField("address.ALL").ignoreFieldBridge().matching(token+"*")
.createQuery());
bool.should(queryBuilder.keyword()
.wildcard()
.onField("address.country.commonName").ignoreFieldBridge().matching(token+"*")
.createQuery());
bool.should(queryBuilder.keyword()
.wildcard()
.onField("billingAddress.ALL").matching(token+"*")
.createQuery());
bool.should(queryBuilder.keyword()
.wildcard()
.onField("billingAddress.country.commonName").matching(token+"*")
.createQuery());
bool.should(queryBuilder.keyword()
.wildcard()
.onField("email").matching(token+"*")
.createQuery());
}
Query textQuery = bool.createQuery();
return textQuery;
}
示例12: handle
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
public <T> void handle(RestCriteria restCriteria,
Map<String, Query> criteria, QueryBuilder queryBuilder)
throws BadCriteriaValueException, CriteriaIDNotFoundException {
BooleanJunction<?> booleanJunction = queryBuilder.bool();
booleanJunction
.must(queryBuilder.keyword().onField(restCriteria.readCriteriaName()).matching(restCriteria.getParsedValue()).createQuery()).not();
Query query = booleanJunction.createQuery();
criteria.put(restCriteria.readCriteriaId(), query);
}