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


Java SearchContext类代码示例

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


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

示例1: getSortedRecords

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
private List<DDLRecord> getSortedRecords(final HttpServletRequest request, final DDLRecordSet recordSet,
        final String sortByStructureColumnName) throws Exception {

    DDMStructure structure = recordSet.getDDMStructure();
    String indexedSortColumn = DDMIndexerUtil.encodeName(structure.getStructureId(), sortByStructureColumnName, Locale.US);

    SearchContext searchContext = SearchContextFactory.getInstance(request);
    String fieldType = structure.getFieldType(sortByStructureColumnName);
    int sortType = getSortType(fieldType);

    Sort sort = SortFactoryUtil.create(indexedSortColumn, sortType, false);

    searchContext.setSorts(sort);
    Indexer indexer = IndexerRegistryUtil.getIndexer("com.liferay.portlet.dynamicdatalists.util.DDLIndexer");
    Hits results = indexer.search(searchContext);

    return adapt(results);
}
 
开发者ID:permeance,项目名称:liferay-sample-ddl-sort-example,代码行数:19,代码来源:SamplePortletController.java

示例2: getIndexData

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
public Set<Data> getIndexData(
		Model model, Set<Model> relatedModels,
		Set<String> indexAttributesToQuery, long companyId,
		List<Long> groupIds, Date startModifiedDate, Date endModifiedDate)
	throws ParseException, SearchException {

	SearchContext searchContext = getIndexSearchContext(model, companyId);

	BooleanQuery query = getIndexQuery(
		model, groupIds, startModifiedDate, endModifiedDate, searchContext);

	String[] sortAttributes = {"createDate", "modifiedDate"};

	Sort[] sorts = getIndexSorting(model, sortAttributes);

	return getIndexData(
		model, relatedModels, indexAttributesToQuery.toArray(new String[0]),
		sorts, searchContext, query);
}
 
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:20,代码来源:IndexSearchHelper.java

示例3: postProcessSearchQuery

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {
            
    boolean advancedSearch = GetterUtil.getBoolean(searchContext.getAttribute("advancedSearch"), false);

    addSearchTerm(searchQuery, searchContext, "description", false);
    if (!advancedSearch) {
        addSearchTerm(searchQuery, searchContext, "workPackage", true);
    }
    
    // TODO: add ticketURL

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:24,代码来源:TaskRecordIndexer.java

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

示例5: getFormDataById

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
	public JSONObject getFormDataById(long companyId, LinkedHashMap<String, Object> params, Sort[] sorts, int start, int end,
			ServiceContext serviceContext) {
		JSONObject result = JSONFactoryUtil.createJSONObject();
		
		Hits hits = null;
		
		SearchContext searchContext = new SearchContext();
		searchContext.setCompanyId(companyId);
		
		try {
			
			hits = DeliverableLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
			
			result.put("data", hits.toList());
			
//			long total = DeliverableLocalServiceUtil.countLucene(params, searchContext);
//			
//			result.put("total", total);
			
		} catch (Exception e) {
			_log.error(e);
		}
		
		return result;
	}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:27,代码来源:DeliverableActionsImpl.java

示例6: getServiceProcesses

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public JSONObject getServiceProcesses(long userId, long companyId, long groupId, LinkedHashMap<String, Object> params,
		Sort[] sorts, int start, int end, ServiceContext serviceContext) throws PortalException {
	JSONObject result = JSONFactoryUtil.createJSONObject();

	Hits hits = null;
	long count = 0;

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);

	hits = ServiceProcessLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
	count = ServiceProcessLocalServiceUtil.countLucene(params, searchContext);

	result.put("total", count);
	result.put("data", hits.toList());

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

示例7: getProcessSteps

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public JSONObject getProcessSteps(long userId, long companyId, long groupId, LinkedHashMap<String, Object> params,
		Sort[] sorts, int start, int end, ServiceContext serviceContext) throws PortalException {

	JSONObject results = JSONFactoryUtil.createJSONObject();

	Hits hits = null;
	long count = 0;

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);

	hits = ProcessStepLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
	count = ProcessStepLocalServiceUtil.countLucene(params, searchContext);

	results.put("total", count);
	results.put("data", hits.toList());

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

示例8: getProcessActions

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public JSONObject getProcessActions(long userId, long companyId, long groupId, LinkedHashMap<String, Object> params,
		Sort[] sorts, int start, int end, ServiceContext serviceContext) throws PortalException {
	JSONObject results = JSONFactoryUtil.createJSONObject();

	Hits hits = null;
	long count = 0;

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);

	hits = ProcessActionLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);
	count = ProcessActionLocalServiceUtil.searchCount(params, searchContext);

	results.put("total", count);
	results.put("data", hits.toList());

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

示例9: getDossierStatistic

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public JSONObject getDossierStatistic(long userId, long companyId, long groupId, LinkedHashMap<String, Object> params,
		Sort[] sorts, int start, int end, ServiceContext serviceContext) {
	JSONObject result = JSONFactoryUtil.createJSONObject();

	Hits hits = null;

	SearchContext searchContext = new SearchContext();
	searchContext.setCompanyId(companyId);

	try {

		hits = DossierStatisticLocalServiceUtil.searchLucene(params, sorts, start, end, searchContext);

		result.put("data", hits.toList());
		result.put("total", hits.toList().size());

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

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

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

示例11: setFacets

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setFacets(SearchContext searchContext)
	throws JSONException {
	
	JSONArray configuration = JSONFactoryUtil.createJSONArray(_gSearchConfiguration.facetConfiguration());

	for (int i = 0; i < configuration.length(); i++) {

		JSONObject item = configuration.getJSONObject(i);

		String fieldName = item.getString("fieldName");
		
		Facet facet = new MultiValueFacet(searchContext);
		facet.setFieldName(fieldName);
		facet.setStatic(false);

		searchContext.addFacet(facet);
	}
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:23,代码来源:FacetsBuilderImpl.java

示例12: postProcessSearchQuery

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery,
        BooleanFilter fullQueryBooleanFilter, SearchContext searchContext)
        throws Exception {

    addSearchTerm(searchQuery, searchContext, "data", false);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext
            .getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:19,代码来源:MeasurementIndexer.java

示例13: postProcessFullQuery

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public void postProcessFullQuery(
		BooleanQuery fullQuery, SearchContext searchContext)
	throws Exception {

	if (_log.isInfoEnabled()) {
		_log.info("postProcessFullQuery");
	}
}
 
开发者ID:liferay,项目名称:liferay-blade-samples,代码行数:10,代码来源:MultipleIndexerPostProcessor.java

示例14: getDateTermRangeQuery

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
protected TermRangeQuery getDateTermRangeQuery(
	SearchContext searchContext, Model model, String field, Date startDate,
	Date endDate) {

	String lowerTerm = null;
	String upperTerm = null;

	if (startDate != null) {
		lowerTerm = DataUtil.dateToString(startDate);
	}

	if (endDate != null) {
		upperTerm = DataUtil.dateToString(endDate);
	}

	field = ConfigurationUtil.getIndexAttributeName(model, field);

	return TermRangeQueryFactoryUtil.create(
		searchContext, field, lowerTerm, upperTerm, true, true);
}
 
开发者ID:jorgediaz-lr,项目名称:index-checker,代码行数:21,代码来源:IndexSearchHelper.java

示例15: search

import com.liferay.portal.kernel.search.SearchContext; //导入依赖的package包/类
@Override
public Hits search(SearchContext searchContext, Query query) throws SearchException {
    try {
        int end = searchContext.getEnd();
        int start = searchContext.getStart();
        if (isFilterSearch(searchContext)) {
            if (end > INDEX_FILTER_SEARCH_LIMIT) {
                end = end - INDEX_FILTER_SEARCH_LIMIT + 5;
            }
            if ((start < 0) || (start > end) || end < 0) {
                return new HitsImpl();
            }
        }
        query = getPermissionQuery(searchContext, query);

        return doSearch(searchContext, query, start, end);
    } catch (Exception e) {
        throw new SearchException(e);
    }
}
 
开发者ID:R-Knowsys,项目名称:elasticray,代码行数:21,代码来源:ElasticsearchIndexSearcher.java


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