List of usage examples for com.liferay.portal.kernel.search Field NAME
String NAME
To view the source code for com.liferay.portal.kernel.search Field NAME.
Click Source Link
From source file:com.library.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
public List<LMSBook> AdvanceSearchAny(long companyId, long groupId, String title, String author, String desc) { SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setEntryClassNames(CLASS_NAMES); BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext); Hits hits = null;/*from w ww . j a v a 2 s .c om*/ try { String[] terms = { Field.TITLE, Field.DESCRIPTION, Field.NAME }; searchQuery.addTerms(terms, getModelClassName()); searchQuery = createQuery(getModelClassName(), getModelClassName(), searchContext, searchQuery); hits = SearchEngineUtil.search(searchContext, searchQuery); } catch (SearchException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<LMSBook> books = null; if (hits != null && hits.getLength() > 0) { books = new ArrayList<LMSBook>(); for (Document document : hits.getDocs()) { long bookId = Long.parseLong(document.get(Field.ENTRY_CLASS_PK)); try { LMSBook book = LMSBookLocalServiceUtil.getLMSBook(bookId); books.add(book); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return books; }
From source file:com.library.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
public List<LMSBook> advanceSearchAll(long companyId, long groupId, String title, String author, String desc, String type) {//from w w w. j a va 2 s. co m SearchContext searchContext = new SearchContext(); searchContext.setCompanyId(companyId); searchContext.setEntryClassNames(CLASS_NAMES); BooleanQuery contextQuery = BooleanQueryFactoryUtil.create(searchContext); contextQuery.addRequiredTerm(Field.COMPANY_ID, companyId); contextQuery.addRequiredTerm(Field.PORTLET_ID, Long.toString(ClassNameLocalServiceUtil.getClassNameId(LMSBook.class))); BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(searchContext); fullQuery.setQueryConfig(searchContext.getQueryConfig()); try { fullQuery.add(contextQuery, BooleanClauseOccur.MUST); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(searchContext); Hits hits = null; if (Validator.isNotNull(title)) { Sort sort = new Sort(Field.TITLE, true); searchContext.setSorts(new Sort[] { sort }); fullQuery = createQuery(Field.TITLE, title, searchContext, fullQuery); } if (Validator.isNotNull(author)) { fullQuery = createQuery(Field.NAME, author, searchContext, fullQuery); } if (Validator.isNotNull(desc)) { fullQuery = createQuery(Field.DESCRIPTION, desc, searchContext, fullQuery); } if (searchQuery.clauses().size() > 0) { try { fullQuery.add(searchQuery, BooleanClauseOccur.MUST); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } try { hits = SearchEngineUtil.search(searchContext, fullQuery); } catch (SearchException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<LMSBook> books = new ArrayList<LMSBook>(); if (hits != null && hits.getLength() > 0) { for (Document document : hits.getDocs()) { long bookId = Long.parseLong(document.get(Field.ENTRY_CLASS_PK)); try { LMSBook book = LMSBookLocalServiceUtil.getLMSBook(bookId); books.add(book); } catch (PortalException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return books; }
From source file:com.liferay.asset.categories.internal.search.AssetCategoryIndexer.java
License:Open Source License
@Override protected Document doGetDocument(AssetCategory assetCategory) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing asset category " + assetCategory); }//w w w .j a v a 2 s.c o m Document document = getBaseModelDocument(CLASS_NAME, assetCategory); document.addKeyword(Field.ASSET_CATEGORY_ID, assetCategory.getCategoryId()); List<AssetCategory> categories = new ArrayList<>(1); categories.add(assetCategory); addSearchAssetCategoryTitles(document, Field.ASSET_CATEGORY_TITLE, categories); document.addKeyword(Field.ASSET_PARENT_CATEGORY_ID, assetCategory.getParentCategoryId()); document.addKeyword(Field.ASSET_VOCABULARY_ID, assetCategory.getVocabularyId()); Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetCategory.getGroupId()); addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetCategory.getDescriptionMap()); document.addText(Field.NAME, assetCategory.getName()); addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetCategory.getTitleMap()); document.addKeyword("leftCategoryId", assetCategory.getLeftCategoryId()); if (_log.isDebugEnabled()) { _log.debug("Document " + assetCategory + " indexed successfully"); } return document; }
From source file:com.liferay.asset.categories.internal.search.AssetVocabularyIndexer.java
License:Open Source License
@Override protected Document doGetDocument(AssetVocabulary assetVocabulary) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing asset vocabulary " + assetVocabulary); }/* w w w . j a v a2s .co m*/ Document document = getBaseModelDocument(CLASS_NAME, assetVocabulary); document.addKeyword(Field.ASSET_VOCABULARY_ID, assetVocabulary.getVocabularyId()); Locale siteDefaultLocale = _portal.getSiteDefaultLocale(assetVocabulary.getGroupId()); addLocalizedField(document, Field.DESCRIPTION, siteDefaultLocale, assetVocabulary.getDescriptionMap()); document.addText(Field.NAME, assetVocabulary.getName()); addLocalizedField(document, Field.TITLE, siteDefaultLocale, assetVocabulary.getTitleMap()); if (_log.isDebugEnabled()) { _log.debug("Document " + assetVocabulary + " indexed successfully"); } return document; }
From source file:com.liferay.asset.tags.admin.web.internal.display.context.AssetTagsDisplayContext.java
License:Open Source License
public SearchContainer getTagsSearchContainer() throws PortalException { if (_tagsSearchContainer != null) { return _tagsSearchContainer; }/* w w w. ja va 2 s . c o m*/ SearchContainer tagsSearchContainer = new SearchContainer(_renderRequest, _renderResponse.createRenderURL(), null, "there-are-no-tags"); String keywords = getKeywords(); if (Validator.isNull(keywords)) { if (isShowAddButton()) { tagsSearchContainer.setEmptyResultsMessage("there-are-no-tags.-you-can-add-a-tag-by-clicking-the-" + "plus-button-on-the-bottom-right-corner"); tagsSearchContainer .setEmptyResultsMessageCssClass("taglib-empty-result-message-header-has-plus-btn"); } } else { tagsSearchContainer.setSearch(true); } tagsSearchContainer.setRowChecker(new EmptyOnClickRowChecker(_renderResponse)); ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); if (Validator.isNotNull(keywords)) { Sort sort = null; String orderByCol = getOrderByCol(); if (orderByCol.equals("name")) { sort = SortFactoryUtil.getSort(AssetTag.class, Sort.STRING_TYPE, Field.NAME, getOrderByType()); } else if (orderByCol.equals("usages")) { sort = SortFactoryUtil.getSort(AssetTag.class, Sort.INT_TYPE, "assetCount_Number", getOrderByType()); } BaseModelSearchResult<AssetTag> baseModelSearchResult = AssetTagLocalServiceUtil.searchTags( new long[] { themeDisplay.getScopeGroupId() }, keywords, tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(), sort); tagsSearchContainer.setResults(baseModelSearchResult.getBaseModels()); tagsSearchContainer.setTotal(baseModelSearchResult.getLength()); } else { String orderByCol = getOrderByCol(); tagsSearchContainer.setOrderByCol(orderByCol); OrderByComparator<AssetTag> orderByComparator = null; boolean orderByAsc = false; String orderByType = getOrderByType(); if (orderByType.equals("asc")) { orderByAsc = true; } if (orderByCol.equals("name")) { orderByComparator = new AssetTagNameComparator(orderByAsc); } else if (orderByCol.equals("usages")) { orderByComparator = new AssetTagAssetCountComparator(orderByAsc); } tagsSearchContainer.setOrderByComparator(orderByComparator); tagsSearchContainer.setOrderByType(orderByType); long scopeGroupId = themeDisplay.getScopeGroupId(); int tagsCount = AssetTagServiceUtil.getTagsCount(scopeGroupId, keywords); tagsSearchContainer.setTotal(tagsCount); List<AssetTag> tags = AssetTagServiceUtil.getTags(scopeGroupId, StringPool.BLANK, tagsSearchContainer.getStart(), tagsSearchContainer.getEnd(), tagsSearchContainer.getOrderByComparator()); tagsSearchContainer.setResults(tags); } _tagsSearchContainer = tagsSearchContainer; return _tagsSearchContainer; }
From source file:com.liferay.asset.tags.internal.search.AssetTagIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { String name = (String) searchContext.getAttribute(Field.NAME); if (Validator.isNotNull(name)) { BooleanQuery nameQuery = new BooleanQueryImpl(); addSearchTerm(nameQuery, searchContext, Field.NAME, true); searchQuery.add(nameQuery, BooleanClauseOccur.SHOULD); }/*from w w w .ja v a2s .c o m*/ }
From source file:com.liferay.asset.tags.internal.search.AssetTagIndexer.java
License:Open Source License
@Override protected Document doGetDocument(AssetTag assetTag) throws Exception { if (_log.isDebugEnabled()) { _log.debug("Indexing asset tag " + assetTag); }//from w ww.j av a 2 s. c o m Document document = getBaseModelDocument(CLASS_NAME, assetTag); document.addTextSortable(Field.NAME, assetTag.getName()); document.addNumberSortable("assetCount", assetTag.getAssetCount()); if (_log.isDebugEnabled()) { _log.debug("Document " + assetTag + " indexed successfully"); } return document; }
From source file:com.liferay.calendar.search.CalendarIndexer.java
License:Open Source License
public CalendarIndexer() { setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID); setDefaultSelectedLocalizedFieldNames(Field.DESCRIPTION, Field.NAME, "resourceName"); setFilterSearch(true);/*w w w .j a v a 2 s .c om*/ setPermissionAware(true); setSelectAllLocales(true); }
From source file:com.liferay.calendar.search.CalendarIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, true); addSearchLocalizedTerm(searchQuery, searchContext, Field.NAME, true); addSearchLocalizedTerm(searchQuery, searchContext, "resourceName", true); }
From source file:com.liferay.calendar.search.CalendarIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Calendar calendar) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, calendar); document.addLocalizedKeyword(Field.DESCRIPTION, calendar.getDescriptionMap(), true); document.addLocalizedKeyword(Field.NAME, calendar.getNameMap(), true); document.addKeyword("calendarId", calendar.getCalendarId()); Locale defaultLocale = LocaleUtil.getSiteDefault(); String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale); document.addText("defaultLanguageId", defaultLanguageId); CalendarResource calendarResource = calendar.getCalendarResource(); document.addLocalizedKeyword("resourceName", calendarResource.getNameMap(), true); return document; }