本文整理汇总了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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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");
}
}
示例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);
}
示例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);
}
}