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


Java SearchContext.setEntryClassNames方法代码示例

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


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

示例1: searchLucene

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
public Hits searchLucene(LinkedHashMap<String, Object> params, Sort[] sorts, int start, int end,
		SearchContext searchContext) throws ParseException, SearchException {
	String keywords = (String) params.get(Field.KEYWORD_SEARCH);
	String groupId = (String) params.get(Field.GROUP_ID);

	Indexer<Registration> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Registration.class);

	searchContext.addFullQueryEntryClassName(CLASS_NAME);
	searchContext.setEntryClassNames(new String[] { CLASS_NAME });
	searchContext.setAttribute("paginationType", "regular");
	searchContext.setLike(true);
	searchContext.setStart(start);
	searchContext.setEnd(end);
	searchContext.setAndSearch(true);
	searchContext.setSorts(sorts);

	BooleanQuery booleanQuery = null;

	if (Validator.isNotNull(keywords)) {
		booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
	} else {
		booleanQuery = indexer.getFullQuery(searchContext);
	}

	if (Validator.isNotNull(groupId)) {
		MultiMatchQuery query = new MultiMatchQuery(groupId);

		query.addFields(Field.GROUP_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}


	booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, CLASS_NAME);

	return IndexSearcherHelperUtil.search(searchContext, booleanQuery);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:38,代码来源:RegistrationLogLocalServiceImpl.java

示例2: countLucense

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
public long countLucense(LinkedHashMap<String, Object> params, Sort[] sorts, int start, int end,
		SearchContext searchContext) throws ParseException, SearchException {
	String keywords = (String) params.get(Field.KEYWORD_SEARCH);
	String groupId = (String) params.get(Field.GROUP_ID);

	Indexer<Registration> indexer = IndexerRegistryUtil.nullSafeGetIndexer(Registration.class);

	searchContext.addFullQueryEntryClassName(CLASS_NAME);
	searchContext.setEntryClassNames(new String[] { CLASS_NAME });
	searchContext.setAttribute("paginationType", "regular");
	searchContext.setLike(true);
	searchContext.setAndSearch(true);

	BooleanQuery booleanQuery = null;

	if (Validator.isNotNull(keywords)) {
		booleanQuery = BooleanQueryFactoryUtil.create(searchContext);
	} else {
		booleanQuery = indexer.getFullQuery(searchContext);
	}

	if (Validator.isNotNull(groupId)) {
		MultiMatchQuery query = new MultiMatchQuery(groupId);

		query.addFields(Field.GROUP_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}

	booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, CLASS_NAME);

	return IndexSearcherHelperUtil.searchCount(searchContext, booleanQuery);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:34,代码来源:RegistrationLogLocalServiceImpl.java

示例3: countLuceneSearchEngine

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
public long countLuceneSearchEngine(LinkedHashMap<String, Object> params,
		SearchContext searchContext) throws ParseException, SearchException {
	// TODO
	MultiMatchQuery query = null;
	String keywords = (String) params.get("keywords");
	String groupId = (String) params.get("groupId");
	String userId = (String) params.get("userId");
	Indexer<OfficeSite> indexer = IndexerRegistryUtil.nullSafeGetIndexer(OfficeSite.class);

	searchContext.addFullQueryEntryClassName(OfficeSite.class.getName());
	searchContext.setEntryClassNames(new String[] { OfficeSite.class.getName() });
	searchContext.setAttribute("paginationType", "regular");
	searchContext.setLike(true);
	searchContext.setAndSearch(true);

	BooleanQuery booleanQuery = null;

	booleanQuery = Validator.isNotNull((String) keywords)
			? BooleanQueryFactoryUtil.create((SearchContext) searchContext) : indexer.getFullQuery(searchContext);

	if (Validator.isNotNull(groupId)) {
		query = new MultiMatchQuery(groupId);

		query.addFields(OfficeSiteTerm.GROUP_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}

	if (Validator.isNotNull(userId)) {
		query = new MultiMatchQuery(userId);

		query.addFields(OfficeSiteTerm.USER_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}

	booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, OfficeSite.class.getName());

	return IndexSearcherHelperUtil.searchCount(searchContext, booleanQuery);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:41,代码来源:OfficeSiteLocalServiceImpl.java

示例4: getIndexSearchContext

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
protected SearchContext getIndexSearchContext(Model model, long companyId) {
	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);
	searchContext.setEntryClassNames(new String[] {model.getClassName()});

	return searchContext;
}
 
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:8,代码来源:IndexSearchHelper.java

示例5: buildQuerySearch

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
/**
 * @param pattern
 * @param params
 * @param searchContext
 * @return
 */

public static BooleanQuery buildQuerySearch(String pattern,
		List<Object> params, SearchContext searchContext) {
	searchContext
			.setEntryClassNames(new String[] { Dossier.class.getName() });

	Indexer indexer = IndexerRegistryUtil.getIndexer(Dossier.class
			.getName());

	searchContext.setSearchEngineId(indexer.getSearchEngineId());

	BooleanQuery query = BooleanQueryFactoryUtil.create(searchContext);
	List<String> subQueries = new ArrayList<String>();
	try {
		pattern = validPattern(pattern);

		if (Validator.isNull(pattern)) {
			throw new Exception();
		}
		getSubQueries(pattern, subQueries);

		if (subQueries != null && !subQueries.isEmpty()) {
			List<BooleanQuery> booleanQueries = createBooleanQueries(
					subQueries, params, searchContext);

			List<BooleanClauseOccur> conditions = getBooleanClauseOccurs(
					pattern, subQueries);

			if (booleanQueries.size() - 1 != conditions.size()) {
				throw new Exception();
			}
			int count = 0;
			for (BooleanQuery booleanQuery : booleanQueries) {
				if (count == 0) {
					query.add(booleanQuery, BooleanClauseOccur.MUST);
				} else {
					query.add(booleanQuery, conditions.get(count - 1));
				}

				count++;
			}
		}

		TermQuery entryClassNameTerm = TermQueryFactoryUtil.create(
				searchContext, "entryClassName", Dossier.class.getName());

		query.add(entryClassNameTerm, BooleanClauseOccur.MUST);

	} catch (Exception e) {
		_log.error(e);
	}

	return query;
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:61,代码来源:LuceneQueryUtil.java

示例6: luceneSearchEngine

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
public Hits luceneSearchEngine(LinkedHashMap<String, Object> params, Sort[] sorts, int start, int end,
		SearchContext searchContext) throws ParseException, SearchException {
	// TODO
	MultiMatchQuery query = null;
	String keywords = (String) params.get("keywords");
	String groupId = (String) params.get("groupId");
	String userId = (String) params.get("userId");
	Indexer<OfficeSite> indexer = IndexerRegistryUtil.nullSafeGetIndexer(OfficeSite.class);

	searchContext.addFullQueryEntryClassName(OfficeSite.class.getName());
	searchContext.setEntryClassNames(new String[] { OfficeSite.class.getName() });
	searchContext.setAttribute("paginationType", "regular");
	searchContext.setLike(true);
	searchContext.setStart(start);
	searchContext.setEnd(end);
	searchContext.setAndSearch(true);
	searchContext.setSorts(sorts);

	BooleanQuery booleanQuery = null;

	booleanQuery = Validator.isNotNull((String) keywords)
			? BooleanQueryFactoryUtil.create((SearchContext) searchContext) : indexer.getFullQuery(searchContext);

	if (Validator.isNotNull(groupId)) {
		query = new MultiMatchQuery(groupId);

		query.addFields(OfficeSiteTerm.GROUP_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}

	if (Validator.isNotNull(userId)) {
		query = new MultiMatchQuery(userId);

		query.addFields(OfficeSiteTerm.USER_ID);

		booleanQuery.add(query, BooleanClauseOccur.MUST);
	}

	booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, OfficeSite.class.getName());

	return IndexSearcherHelperUtil.search(searchContext, booleanQuery);
}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:44,代码来源:OfficeSiteLocalServiceImpl.java


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