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


Java SearchContext.setEnd方法代码示例

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


在下文中一共展示了SearchContext.setEnd方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSearchContext

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
/**
 * Get searchcontext.
 * 
 * @return searchcontext object
 * @throws Exception 
 */
protected SearchContext getSearchContext() throws Exception {

	ThemeDisplay themeDisplay =
		(ThemeDisplay) _portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(themeDisplay.getCompanyId());
	searchContext.setStart(_queryParams.getStart());
	searchContext.setEnd(_queryParams.getEnd());
	searchContext.setSorts(_queryParams.getSorts());

	// Set facets.

	_facetsBuilder.setFacets(searchContext);

	return searchContext;
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:24,代码来源:GSearchImpl.java

示例3: buildSearchContext

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
protected SearchContext buildSearchContext(long userId, long groupId, long ownerUserId, String workPackage,
        String description, int status, Date fromDate, Date untilDate, LinkedHashMap<String, Object> params,
        boolean andSearch, boolean advancedSearch, int start, int end, Sort sort) throws PortalException {

    SearchContext searchContext = new SearchContext();

    searchContext.setAttribute("advancedSearch", advancedSearch);

    searchContext.setAttribute(Field.STATUS, status);

    if (Validator.isNotNull(description)) {
        searchContext.setAttribute("description", description);
    }

    searchContext.setAttribute("fromDate", fromDate);
    searchContext.setAttribute("untilDate", untilDate);

    if (Validator.isNotNull(workPackage)) {
        searchContext.setAttribute("workPackage", workPackage);
    }

    searchContext.setAttribute("paginationType", "more");

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    searchContext.setCompanyId(group.getCompanyId());

    if (ownerUserId > 0) {
        searchContext.setOwnerUserId(ownerUserId);
    }

    searchContext.setEnd(end);
    if (groupId > 0) {
        searchContext.setGroupIds(new long[] { groupId });
    }
    searchContext.setSorts(sort);
    searchContext.setStart(start);
    searchContext.setUserId(userId);

    searchContext.setAndSearch(andSearch);

    if (params != null) {

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    QueryConfig queryConfig = new QueryConfig();

    queryConfig.setHighlightEnabled(false);
    queryConfig.setScoreEnabled(false);

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:66,代码来源:TaskRecordLocalServiceImpl.java

示例4: buildSearchContext

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
protected SearchContext buildSearchContext(long userId, long groupId, long ownerUserId, String company,
        String fullName, int status, LinkedHashMap<String, Object> params, boolean andSearch, int start, int end,
        Sort sort) throws PortalException {

    SearchContext searchContext = new SearchContext();

    searchContext.setAttribute(Field.STATUS, status);

    if (Validator.isNotNull(company)) {
        searchContext.setAttribute("company", company);
    }

    if (Validator.isNotNull(fullName)) {
        searchContext.setAttribute("fullName", fullName);
    }

    searchContext.setAttribute("paginationType", "more");

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    searchContext.setCompanyId(group.getCompanyId());

    if (ownerUserId > 0) {
        searchContext.setOwnerUserId(ownerUserId);
    }

    searchContext.setEnd(end);
    if (groupId > 0) {
        searchContext.setGroupIds(new long[] { groupId });
    }
    searchContext.setSorts(sort);
    searchContext.setStart(start);
    searchContext.setUserId(userId);

    searchContext.setAndSearch(andSearch);

    if (params != null) {

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    QueryConfig queryConfig = new QueryConfig();

    queryConfig.setHighlightEnabled(false);
    queryConfig.setScoreEnabled(false);

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:61,代码来源:ContactLocalServiceImpl.java

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

示例6: buildSearchContext

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
protected SearchContext buildSearchContext(long userId, long groupId,
        String data, String id, String name, String range, Date timestamp,
        Date fromDate, Date untilDate, LinkedHashMap<String, Object> params,
        boolean andSearch, int start, int end, Sort sort)
        throws PortalException {

    SearchContext searchContext = new SearchContext();

    searchContext.setAttribute("advancedSearch", true);

    searchContext.setAttribute(Field.STATUS, WorkflowConstants.STATUS_ANY);

    if (Validator.isNotNull(data)) {
        searchContext.setAttribute("data", data);
    }

    if (Validator.isNotNull(id)) {
        searchContext.setAttribute("id", id);
    }

    if (Validator.isNotNull(name)) {
        searchContext.setAttribute("name", name);
    }

    if (Validator.isNotNull(range)) {
        searchContext.setAttribute("range", range);
    }

    if (Validator.isNotNull(timestamp)) {
        searchContext.setAttribute("timestamp", timestamp.getTime());
    }

    if (Validator.isNotNull(fromDate)) {
        searchContext.setAttribute("fromDate", fromDate);
    }

    if (Validator.isNotNull(untilDate)) {
        searchContext.setAttribute("untilDate", untilDate);
    }

    searchContext.setAttribute("paginationType", "more");

    Group group = GroupLocalServiceUtil.getGroup(groupId);

    searchContext.setCompanyId(group.getCompanyId());

    searchContext.setEnd(end);
    if (groupId > 0) {
        searchContext.setGroupIds(new long[] { groupId });
    }
    searchContext.setSorts(sort);
    searchContext.setStart(start);
    searchContext.setUserId(userId);

    searchContext.setAndSearch(andSearch);

    if (params != null) {

        String keywords = (String) params.remove("keywords");

        if (Validator.isNotNull(keywords)) {
            searchContext.setKeywords(keywords);
        }
    }

    QueryConfig queryConfig = new QueryConfig();

    queryConfig.setHighlightEnabled(false);
    queryConfig.setScoreEnabled(false);

    searchContext.setQueryConfig(queryConfig);

    if (sort != null) {
        searchContext.setSorts(sort);
    }

    searchContext.setStart(start);

    return searchContext;
}
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:81,代码来源:MeasurementLocalServiceImpl.java

示例7: executeSearch

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
protected Document[] executeSearch(
		SearchContext searchContext, BooleanQuery query, Sort[] sorts,
		TermRangeQuery termRangeQuery, String[] indexFields, int size)
	throws ParseException, SearchException {

	BooleanQuery mainQuery = BooleanQueryFactoryUtil.create(searchContext);

	mainQuery.add(query, BooleanClauseOccur.MUST);

	if (termRangeQuery != null) {
		mainQuery.add(termRangeQuery, BooleanClauseOccur.MUST);
	}

	if (sorts.length > 0) {
		searchContext.setSorts(sorts);
	}

	if (_log.isDebugEnabled()) {
		_log.debug("size: " + size);
		_log.debug("Executing search: " + mainQuery);
	}

	searchContext.setStart(0);
	searchContext.setEnd(size);

	QueryConfig queryConfig = new QueryConfig();
	queryConfig.setHighlightEnabled(false);
	queryConfig.setScoreEnabled(false);

	if (indexFields != null) {
		queryConfig.setSelectedFieldNames(indexFields);
	}

	mainQuery.setQueryConfig(queryConfig);
	searchContext.setQueryConfig(queryConfig);

	Hits hits = SearchEngineUtil.search(searchContext, mainQuery);

	Document[] docs = hits.getDocs();

	if (_log.isDebugEnabled()) {
		_log.debug(docs.length + " hits returned");
	}

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

示例8: getSearchResults

import com.liferay.portal.kernel.search.SearchContext; //导入方法依赖的package包/类
/**
 *Method that get list of results for the keyword search by user
 */
public static List<MBThread> getSearchResults(HttpServletRequest request,long searchCategoryId,SearchContainer searchContainer){
	_log.debug("Entry : getSearchResults");
	List<MBThread> threadsList=new ArrayList<>();
	try{
			String keywords = ParamUtil.getString(request, CustomConstants.KEYWORDS);
			ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
			long[] finalSearchCategoryIdsArray = null;
			List<Long> searchCategoryIds = new ArrayList<>();
			List<Long> finalSearchCategoryIds=new ArrayList<>();
			PortletPreferences preference=(PortletPreferences)request.getAttribute(CustomConstants.PREFERENCE_REQUEST_ATTRIBUTE);
			long preferenceCatId=GetterUtil.getLong(preference.getValue(CustomConstants.PREFERENCE_CATEGORYID, String.valueOf(QueryUtil.ALL_POS)));
			List<Long> categoryIds=new ArrayList<Long>();
			MBCategoryServiceUtil.getSubcategoryIds(
					searchCategoryIds, themeDisplay.getScopeGroupId(), searchCategoryId);
			searchCategoryIds.add(Long.valueOf(searchCategoryId));
			if(preferenceCatId != QueryUtil.ALL_POS){
				categoryIds=getPreferenceCatChildList(preferenceCatId, request);
				for(long preferenceCat:categoryIds){
					for(long searchCat:searchCategoryIds){
						if(preferenceCat == searchCat){
							finalSearchCategoryIds.add(searchCat);
						}
					}
				}
			}
			else{
				finalSearchCategoryIds.addAll(searchCategoryIds);
			}
			finalSearchCategoryIdsArray= StringUtil.split(
					StringUtil.merge(finalSearchCategoryIds), 0L);
			
			Indexer indexer = IndexerRegistryUtil.getIndexer(MBMessage.class);
	
			SearchContext searchContext = SearchContextFactory.getInstance(
				request);
	
			searchContext.setAttribute(CustomConstants.PAGINATION_TYPE, CustomConstants.PAGINATION_TYPE_VALUE);
			searchContext.setCategoryIds(finalSearchCategoryIdsArray);
			searchContext.setEnd(searchContainer.getEnd());
			searchContext.setIncludeAttachments(true);
	
			searchContext.setKeywords(keywords);
	
			searchContext.setStart(searchContainer.getStart());
	
			Hits hits = indexer.search(searchContext);
	
			List<SearchResult> searchResults=SearchResultUtil.getSearchResults(hits, request.getLocale());
			
			for(SearchResult searchResult:searchResults){
				threadsList.add(MBThreadLocalServiceUtil.getMBThread(MBMessageLocalServiceUtil.getMBMessage(searchResult.getClassPK()).getThreadId()));
			}
				_log.debug("List Size:=>"+threadsList.size());
			searchContainer.setSearch(true);
			searchContainer.setTotal(hits.getLength());
	}
	catch(Exception e){
		_log.error("Exception while searching",e);
	}
return threadsList;
}
 
开发者ID:Azilen,项目名称:Discussion-Board-Liferay,代码行数:65,代码来源:CustomThreadCategoryList.java


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