List of usage examples for com.liferay.portal.kernel.search QueryConfig addSelectedFieldNames
public void addSelectedFieldNames(String... selectedFieldNames)
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)); }/* w ww .j a v a 2 s. co m*/ 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")); }