当前位置: 首页>>代码示例>>Java>>正文


Java BooleanJunction.should方法代码示例

本文整理汇总了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();
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:8,代码来源:LuceneQueryBuilder.java

示例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();
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:8,代码来源:LuceneQueryBuilder.java

示例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;
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:12,代码来源:HibernateSearchLuceneQueryFactoryImpl.java

示例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();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:15,代码来源:HibernateSearchLuceneQueryFactoryImpl.java

示例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);
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:AbstractHibernateSearchSearchQuery.java

示例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;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:16,代码来源:LuceneSearch.java

示例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;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:9,代码来源:LuceneSearch.java

示例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);
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:34,代码来源:DefaultLuceneQueryBuilder.java

示例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());
    }
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:9,代码来源:DefaultLuceneQueryBuilder.java

示例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());
}
 
开发者ID:jpasearch,项目名称:jpasearch,代码行数:6,代码来源:DefaultLuceneQueryBuilder.java

示例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;
}
 
开发者ID:IHTSDO,项目名称:MLDS,代码行数:49,代码来源:AffiliateSearchRepository.java


注:本文中的org.hibernate.search.query.dsl.BooleanJunction.should方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。