本文整理汇总了Java中org.hibernate.search.query.dsl.BooleanJunction.should方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanJunction.should方法的具体用法?Java BooleanJunction.should怎么用?Java BooleanJunction.should使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.search.query.dsl.BooleanJunction
的用法示例。
在下文中一共展示了BooleanJunction.should方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: 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;
}
示例4: 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();
}
示例5: shouldIfNotNull
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
protected void shouldIfNotNull(BooleanJunction<?> junction, Query ... queries) {
for (Query query : queries) {
if (query != null) {
junction.should(query);
}
}
}
示例6: createEqualsQuery
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private static Query createEqualsQuery(String nameInSource, Object value, boolean and,
boolean not, BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder) {
Query queryKey = queryBuilder.keyword()
.onField(nameInSource)
.matching(value).createQuery();
if (not) {
junction.must(queryKey).not();
} else if (and) {
junction.must(queryKey);
} else if (junction != null) {
junction.should(queryKey);
}
return queryKey;
}
示例7: createLikeQuery
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private static Query createLikeQuery(Column column, String value,
BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder) {
Query queryKey = queryBuilder.phrase()
.onField(column.getNameInSource()).sentence(value)
.createQuery();
junction.should(queryKey);
return queryKey;
}
示例8: build
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
public <T> Query build(FullTextEntityManager fullTextEntityManager, ObjectTermSelector<T> termSelector, Class<? extends T> type) {
QueryBuilder builder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(type).get();
BooleanJunction<?> context = builder.bool();
boolean valid = false;
if (termSelector.isNotEmpty()) {
boolean hasTerms = false;
BooleanJunction<?> termContext = builder.bool();
for (Object selected : termSelector.getSelected()) {
if ((selected != null) && isNotBlank(selected.toString())) {
List<String> fields = termSelector.getPaths();
BooleanJunction<?> valueContext = builder.bool();
addFuzzyMatch(builder, selected, fields, termSelector.getSearchSimilarity(), valueContext);
addKeywordMatch(builder, selected, fields, valueContext);
if (termSelector.isOrMode()) {
termContext.should(valueContext.createQuery());
} else {
termContext.must(valueContext.createQuery());
}
hasTerms = true;
}
}
if (hasTerms) {
context.must(termContext.createQuery());
valid = true;
}
}
return createQuery(builder, context, valid);
}
示例9: addFuzzyMatch
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private <T> void addFuzzyMatch(QueryBuilder builder, Object value, List<String> fields, Integer editDistance, BooleanJunction<?> valueContext) {
if (editDistance != null) {
valueContext.should(builder.keyword().fuzzy() //
.withEditDistanceUpTo(editDistance) //
.onFields(fields.toArray(new String[fields.size()])) //
.matching(value).createQuery());
}
}
示例10: addKeywordMatch
import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private void addKeywordMatch(QueryBuilder builder, Object selected, List<String> fields, BooleanJunction<?> valueContext) {
valueContext.should(builder.keyword() //
.onFields(fields.toArray(new String[fields.size()])) //
.matching(selected).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;
}