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


Java BooleanJunction.must方法代码示例

本文整理汇总了Java中org.hibernate.search.query.dsl.BooleanJunction.must方法的典型用法代码示例。如果您正苦于以下问题:Java BooleanJunction.must方法的具体用法?Java BooleanJunction.must怎么用?Java BooleanJunction.must使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.search.query.dsl.BooleanJunction的用法示例。


在下文中一共展示了BooleanJunction.must方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processKeywords

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Nullable
@SuppressWarnings({ CompilerWarnings.UNCHECKED })
private Long[] processKeywords(EntityManager entityManager, @Nullable Integer maxResults) {
    FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
    QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(this.entityImplClass).get();
    BooleanJunction<?> conjunction = queryBuilder.bool();

    PropertyMetadata keywordPropMetadata;

    for (String keywordPropName : this.keywords.keySet()) {
        conjunction = conjunction.must(queryBuilder.keyword()
            .onFields((keywordPropMetadata = this.entityPropMetadatas.get(keywordPropName)).getLowercaseFieldName(),
                keywordPropMetadata.getEdgeNgramFieldName(), keywordPropMetadata.getNgramFieldName(), keywordPropMetadata.getPhoneticFieldName())
            .matching(StringUtils.join(this.keywords.get(keywordPropName), StringUtils.SPACE)).createQuery());
    }

    FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(new InterceptingQuery(conjunction.createQuery()), this.entityImplClass);
    fullTextQuery.setProjection(ProjectionConstants.ID);

    if (maxResults != null) {
        fullTextQuery.setMaxResults(maxResults);
    }

    return ((List<Object[]>) fullTextQuery.getResultList()).stream().map(fullTextResult -> ((Long) fullTextResult[0])).toArray(Long[]::new);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:26,代码来源:SdcctCriteriaImpl.java

示例2: getSearchByNameQuery

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private FullTextQuery getSearchByNameQuery(String searchTerm) {
	FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
	
	QueryBuilder projectQueryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder()
			.forEntity(Project.class).get();
	
	BooleanJunction<?> booleanJunction = projectQueryBuilder.bool();
	if (StringUtils.hasText(searchTerm)) {
		booleanJunction.must(projectQueryBuilder
				.keyword()
				.fuzzy().withPrefixLength(1).withThreshold(0.8F)
				.onField(Binding.project().name().getPath())
				.matching(searchTerm)
				.createQuery());
	} else {
		booleanJunction.must(projectQueryBuilder.all().createQuery());
	}
	
	return fullTextEntityManager.createFullTextQuery(booleanJunction.createQuery(), Project.class);
}
 
开发者ID:openwide-java,项目名称:artifact-listener,代码行数:21,代码来源:ProjectDaoImpl.java

示例3: getSearchQuery

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private FullTextQuery getSearchQuery(String searchTerm) {
	FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
	
	QueryBuilder userQueryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder()
			.forEntity(User.class).get();
	
	BooleanJunction<?> booleanJunction = userQueryBuilder.bool();
	
	if (StringUtils.hasText(searchTerm)) {
		booleanJunction.must(userQueryBuilder
				.keyword()
				.fuzzy().withPrefixLength(1).withThreshold(0.8F)
				.onField(Binding.user().userName().getPath())
				.andField(Binding.user().fullName().getPath())
				.matching(searchTerm)
				.createQuery());
	} else {
		booleanJunction.must(userQueryBuilder.all().createQuery());
	}
	
	return fullTextEntityManager.createFullTextQuery(booleanJunction.createQuery(), User.class);
}
 
开发者ID:openwide-java,项目名称:artifact-listener,代码行数:23,代码来源:UserDaoImpl.java

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

示例5: searchByKeyword

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
@Override
@Transactional(readOnly = true)
public List<TweetEntity> searchByKeyword(final String keywords, final LocalDate from, final LocalDate to) {
    // Must be retrieved inside a transaction to take part of
    final FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);

    // Prepare a search query builder
    final QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity(TweetEntity.class).get();

    // This is a boolean junction... I'll add at least a keyword query
    final BooleanJunction<BooleanJunction> outer = queryBuilder.bool();
    outer.must(
            queryBuilder
            .keyword()
            .onFields("content")
            .matching(keywords)
            .createQuery()
    );

    // And then 2 range queries if from and to are not null
    Optional.ofNullable(from)
            .map(f -> f.atStartOfDay(UTC)) // Must be a zoned date time to fit the field
            .map(f -> queryBuilder.range().onField("created_at").above(f).createQuery())
            .ifPresent(q -> outer.must(q));
    Optional.ofNullable(to)
            .map(f -> f.plusDays(1).atStartOfDay(UTC)) // Same here, but a day later
            .map(f -> queryBuilder.range().onField("created_at").below(f).excludeLimit().createQuery()) // which i exclude
            .ifPresent(q -> outer.must(q));
    return fullTextEntityManager.createFullTextQuery(outer.createQuery(), TweetEntity.class).getResultList();
}
 
开发者ID:michael-simons,项目名称:tweetarchive,代码行数:31,代码来源:TweetRepositoryImpl.java

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

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

示例8: mustIfNotNull

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
protected void mustIfNotNull(BooleanJunction<?> junction, Query ... queries) {
	for (Query query : queries) {
		if (query != null) {
			junction.must(query);
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:AbstractHibernateSearchSearchQuery.java

示例9: 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

示例10: createRangeAboveQuery

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private static Query createRangeAboveQuery(Column column, Object value,
		BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder) {

	Query queryKey = queryBuilder.range()
			.onField(column.getNameInSource())
			.above(value).excludeLimit().createQuery();
	junction.must(queryKey);
	return queryKey;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:10,代码来源:LuceneSearch.java

示例11: createRangeBelowQuery

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private static Query createRangeBelowQuery(Column column, Object value,
		BooleanJunction<BooleanJunction> junction, QueryBuilder queryBuilder) {

	Query queryKey = queryBuilder.range()
			.onField(column.getNameInSource())
			.below(value).excludeLimit().createQuery();
	junction.must(queryKey);
	return queryKey;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:10,代码来源:LuceneSearch.java

示例12: addTextSearch

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private void addTextSearch(QueryBuilder theQueryBuilder, BooleanJunction<?> theBoolean, List<List<? extends IQueryParameterType>> theTerms, String theFieldName, String theFieldNameEdgeNGram, String theFieldNameNGram) {
		if (theTerms == null) {
			return;
		}
		for (List<? extends IQueryParameterType> nextAnd : theTerms) {
			Set<String> terms = new HashSet<String>();
			for (IQueryParameterType nextOr : nextAnd) {
				StringParam nextOrString = (StringParam) nextOr;
				String nextValueTrimmed = StringUtils.defaultString(nextOrString.getValue()).trim();
				if (isNotBlank(nextValueTrimmed)) {
					terms.add(nextValueTrimmed);
				}
			}
			if (terms.isEmpty() == false) {
				if (terms.size() == 1) {
					//@formatter:off
					Query textQuery = theQueryBuilder
						.phrase()
						.withSlop(2)
						.onField(theFieldName).boostedTo(4.0f)
//						.andField(theFieldNameEdgeNGram).boostedTo(2.0f)
//						.andField(theFieldNameNGram).boostedTo(1.0f)
						.sentence(terms.iterator().next().toLowerCase()).createQuery();
					//@formatter:on

					theBoolean.must(textQuery);
				} else {
					String joinedTerms = StringUtils.join(terms, ' ');
					theBoolean.must(theQueryBuilder.keyword().onField(theFieldName).matching(joinedTerms).createQuery());
				}
			}
		}
	}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:34,代码来源:FulltextSearchSvcImpl.java

示例13: addDisplayFilterInexact

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private void addDisplayFilterInexact(QueryBuilder qb, BooleanJunction<?> bool, ConceptSetFilterComponent nextFilter) {
	Query textQuery = qb
		.phrase()
		.withSlop(2)
		.onField("myDisplay").boostedTo(4.0f)
		.andField("myDisplayEdgeNGram").boostedTo(2.0f)
		// .andField("myDisplayNGram").boostedTo(1.0f)
		// .andField("myDisplayPhonetic").boostedTo(0.5f)
		.sentence(nextFilter.getValue().toLowerCase()).createQuery();
	bool.must(textQuery);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:12,代码来源:HapiTerminologySvcR4.java

示例14: addDisplayFilterInexact

import org.hibernate.search.query.dsl.BooleanJunction; //导入方法依赖的package包/类
private void addDisplayFilterInexact(QueryBuilder qb, BooleanJunction<?> bool, ConceptSetFilterComponent nextFilter) {
	Query textQuery = qb
			.phrase()
			.withSlop(2)
			.onField("myDisplay").boostedTo(4.0f)
			.andField("myDisplayEdgeNGram").boostedTo(2.0f)
			// .andField("myDisplayNGram").boostedTo(1.0f)
			// .andField("myDisplayPhonetic").boostedTo(0.5f)
			.sentence(nextFilter.getValue().toLowerCase()).createQuery();
	bool.must(textQuery);
}
 
开发者ID:jamesagnew,项目名称:hapi-fhir,代码行数:12,代码来源:HapiTerminologySvcDstu3.java

示例15: 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


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