本文整理汇总了Java中com.liferay.portal.kernel.search.Hits类的典型用法代码示例。如果您正苦于以下问题:Java Hits类的具体用法?Java Hits怎么用?Java Hits使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hits类属于com.liferay.portal.kernel.search包,在下文中一共展示了Hits类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSortedRecords
import com.liferay.portal.kernel.search.Hits; //导入依赖的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: getTaskRecords
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
public static List<TaskRecord> getTaskRecords(Hits hits) {
List<Document> documents = ListUtil.toList(hits.getDocs());
List<TaskRecord> taskRecords = new ArrayList<TaskRecord>();
for (Document document : documents) {
try {
long taskRecordId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
TaskRecord taskRecord = TaskRecordLocalServiceUtil.getTaskRecord(taskRecordId);
taskRecords.add(taskRecord);
} catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error(e.getMessage());
}
}
}
return taskRecords;
}
示例3: getContacts
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
public static List<Contact> getContacts(Hits hits) {
List<Document> documents = ListUtil.toList(hits.getDocs());
List<Contact> taskRecords = new ArrayList<Contact>();
for (Document document : documents) {
try {
long taskRecordId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
Contact taskRecord = ContactLocalServiceUtil.getContact(taskRecordId);
taskRecords.add(taskRecord);
} catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error(e.getMessage());
}
}
}
return taskRecords;
}
示例4: searchLucene
import com.liferay.portal.kernel.search.Hits; //导入依赖的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.Hits; //导入依赖的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.Hits; //导入依赖的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.Hits; //导入依赖的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.Hits; //导入依赖的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.Hits; //导入依赖的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: addMeasurement
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
private int addMeasurement(ServiceContext serviceContext, long userId,
JSONObject data, String id, String name, Date timestamp,
String unit, String value) throws Exception {
Hits hits = _measurementLocalService.search(userId,
serviceContext.getScopeGroupId(), null, id, null, null,
timestamp, null, null, null, true, 0, 1, null);
if (hits.getLength() == 0) {
_measurementLocalService.addMeasurement(userId, data.toString(), id,
name, timestamp, unit, value, serviceContext);
return IMPORTED;
} else {
return IGNORED;
}
}
示例11: getMeasurements
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
public static List<Measurement> getMeasurements(Hits hits) {
List<Document> documents = ListUtil.toList(hits.getDocs());
List<Measurement> measurements = new ArrayList<Measurement>();
for (Document document : documents) {
try {
long measurementId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
Measurement measurement = MeasurementLocalServiceUtil.getMeasurement(measurementId);
measurements.add(measurement);
} catch (Exception e) {
if (_log.isErrorEnabled()) {
_log.error(e.getMessage());
}
}
}
return measurements;
}
示例12: search
import com.liferay.portal.kernel.search.Hits; //导入依赖的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);
}
}
示例13: doSearch
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
private Hits doSearch(SearchContext searchContext, Query query, int start, int end) {
Client client = getClient();
SearchRequestBuilder searchRequestBuilder = prepareSearchBuilder(searchContext, query, client, start, end);
_log.debug("Current lucene version: " + Version.LUCENE_CURRENT);
_log.debug("Search query String " + searchRequestBuilder.toString());
SearchRequest searchRequest = searchRequestBuilder.request();
_log.debug("Time Before request to ES: " + System.currentTimeMillis());
ActionFuture<SearchResponse> future = client.search(searchRequest);
SearchResponse searchResponse = future.actionGet();
_log.debug("Time After response from ES: " + System.currentTimeMillis());
updateFacetCollectors(searchContext, searchResponse);
Hits hits = processSearchHits(
searchResponse, query.getQueryConfig());
_log.debug("Total responseCount " + searchResponse.getHits().getTotalHits());
_log.debug("Time After processSearchHits: " + System.currentTimeMillis());
hits.setQuery(query);
TimeValue timeValue = searchResponse.getTook();
hits.setSearchTime((float) timeValue.getSecondsFrac());
return hits;
}
示例14: search
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
@Override
public Hits search(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 {
return taskRecordLocalService.search(userId, groupId, ownerUserId, workPackage, description, status, fromDate,
untilDate, params, andSearch, advancedSearch, start, end, sort);
}
示例15: search
import com.liferay.portal.kernel.search.Hits; //导入依赖的package包/类
@Override
public Hits search(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 {
return contactLocalService.search(userId, groupId, ownerUserId, company, fullName, status, params, andSearch,
start, end, sort);
}