List of usage examples for com.liferay.portal.kernel.search Field PRIORITY
String PRIORITY
To view the source code for com.liferay.portal.kernel.search Field PRIORITY.
Click Source Link
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
private int _getSortType(String fieldType) { int sortType = Sort.STRING_TYPE; if (fieldType.equals(Field.CREATE_DATE) || fieldType.equals(Field.EXPIRATION_DATE) || fieldType.equals(Field.PUBLISH_DATE) || fieldType.equals("ddm-date") || fieldType.equals("modifiedDate")) { sortType = Sort.LONG_TYPE;// w w w . java 2s . c om } else if (fieldType.equals(Field.PRIORITY) || fieldType.equals("ddm-decimal") || fieldType.equals("ddm-number")) { sortType = Sort.DOUBLE_TYPE; } else if (fieldType.equals("ddm-integer")) { sortType = Sort.INT_TYPE; } return sortType; }
From source file:com.liferay.asset.search.test.AssetUtilSearchSortTest.java
License:Open Source License
@Test public void testPriority() throws Exception { double[] priorities = { 10, 1, 40, 5.3 }; for (double priority : priorities) { addJournalArticle(serviceContext -> serviceContext.setAssetPriority(priority)); }/*from w w w. ja v a2 s. c om*/ SearchContext searchContext = createSearchContext(); QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.addSelectedFieldNames(Field.PRIORITY); AssetEntryQuery assetEntryQuery = createAssetEntryQueryOrderBy(Field.PRIORITY); Hits hits = _assetHelper.search(searchContext, assetEntryQuery, QueryUtil.ALL_POS, QueryUtil.ALL_POS); DocumentsAssert.assertValues((String) searchContext.getAttribute("queryString"), hits.getDocs(), Field.PRIORITY, Arrays.asList("1.0", "5.3", "10.0", "40.0")); }
From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java
License:Open Source License
@Test public void testIndexedFields() throws Exception { String originalTitle = "entity title"; String translatedTitle = "entitas neve"; String description = StringUtil.toLowerCase(RandomTestUtil.randomString()); CalendarBooking calendarBooking = addCalendarBooking(new LocalizedValuesMap() { {/*from www . ja v a 2 s . com*/ put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, originalTitle); put(LocaleUtil.HUNGARY, translatedTitle); } }, new LocalizedValuesMap() { { put(LocaleUtil.US, description); put(LocaleUtil.HUNGARY, description); } }); Map<String, String> map = new HashMap<>(); map.put(Field.CLASS_NAME_ID, String.valueOf(portal.getClassNameId(Calendar.class))); map.put(Field.EXPIRATION_DATE, "99950812133000"); map.put(Field.EXPIRATION_DATE.concat("_sortable"), "9223372036854775807"); map.put(Field.PRIORITY, "0.0"); map.put(Field.PUBLISH_DATE, "19700101000000"); map.put(Field.PUBLISH_DATE.concat("_sortable"), "0"); map.put(Field.RELATED_ENTRY, "true"); map.put(Field.STAGING_GROUP, "false"); map.put(Field.STATUS, "0"); map.put("viewActionId", CalendarActionKeys.VIEW_BOOKING_DETAILS); populateTitle(originalTitle, map); populateTranslatedTitle(translatedTitle, map); CalendarResource calendarResource = calendarBooking.getCalendarResource(); populateCalendarResource(calendarResource, map); Calendar calendar = calendarResource.getDefaultCalendar(); populateCalendar(calendar, map); populateCalendarBooking(calendarBooking, map); DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat("yyyyMMddHHmm"); populateCalendarDate(Field.CREATE_DATE, calendar.getCreateDate(), dateFormat, map); populateCalendarDate(Field.MODIFIED_DATE, calendar.getModifiedDate(), dateFormat, map); calendarFieldsFixture.populateGroupRoleId(map); calendarFieldsFixture.populateRoleId("Owner", map); calendarFieldsFixture.populateUID(calendarBooking, map); String keywords = "nev"; Document document = calendarSearchFixture.searchOnlyOne(keywords, LocaleUtil.HUNGARY); adjustDatePrecision(Field.CREATE_DATE, document, dateFormat); adjustDatePrecision(Field.MODIFIED_DATE, document, dateFormat); FieldValuesAssert.assertFieldValues(map, document, keywords); }