List of usage examples for com.liferay.portal.kernel.search Field TITLE
String TITLE
To view the source code for com.liferay.portal.kernel.search Field TITLE.
Click Source Link
From source file:com.liferay.portlet.softwarecatalog.util.SCIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { String title = document.get(Field.TITLE); String content = snippet;/*from w w w .j av a 2 s.c om*/ if (Validator.isNull(snippet)) { content = StringUtil.shorten(document.get(Field.CONTENT), 200); } String productEntryId = document.get(Field.ENTRY_CLASS_PK); portletURL.setParameter("struts_action", "/software_catalog/view_product_entry"); portletURL.setParameter("productEntryId", productEntryId); return new Summary(title, content, portletURL); }
From source file:com.liferay.portlet.tags.service.impl.TagsAssetLocalServiceImpl.java
License:Open Source License
public Hits search(long companyId, String portletId, String keywords, int start, int end) throws SystemException { try {/*from w w w . ja v a2 s . c o m*/ BooleanQuery contextQuery = BooleanQueryFactoryUtil.create(); if (Validator.isNotNull(portletId)) { contextQuery.addRequiredTerm(Field.PORTLET_ID, portletId); } else { BooleanQuery portletIdsQuery = BooleanQueryFactoryUtil.create(); for (String assetTypePortletId : TagsUtil.ASSET_TYPE_PORTLET_IDS) { TermQuery termQuery = TermQueryFactoryUtil.create(Field.PORTLET_ID, assetTypePortletId); portletIdsQuery.add(termQuery, BooleanClauseOccur.SHOULD); } contextQuery.add(portletIdsQuery, BooleanClauseOccur.MUST); } BooleanQuery searchQuery = BooleanQueryFactoryUtil.create(); if (Validator.isNotNull(keywords)) { searchQuery.addTerm(Field.TITLE, keywords); searchQuery.addTerm(Field.CONTENT, keywords); searchQuery.addTerm(Field.DESCRIPTION, keywords); searchQuery.addTerm(Field.PROPERTIES, keywords); searchQuery.addTerm(Field.TAGS_ENTRIES, keywords); } BooleanQuery fullQuery = BooleanQueryFactoryUtil.create(); fullQuery.add(contextQuery, BooleanClauseOccur.MUST); if (searchQuery.clauses().size() > 0) { fullQuery.add(searchQuery, BooleanClauseOccur.MUST); } return SearchEngineUtil.search(companyId, fullQuery, start, end); } catch (Exception e) { throw new SystemException(e); } }
From source file:com.liferay.portlet.tags.service.impl.TagsAssetLocalServiceImpl.java
License:Open Source License
protected TagsAsset getAsset(Document doc) throws PortalException, SystemException { String portletId = GetterUtil.getString(doc.get(Field.PORTLET_ID)); if (portletId.equals(PortletKeys.BLOGS)) { long entryId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)); long classNameId = PortalUtil.getClassNameId(BlogsEntry.class.getName()); long classPK = entryId; return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.BOOKMARKS)) { long entryId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)); long classNameId = PortalUtil.getClassNameId(BookmarksEntry.class.getName()); long classPK = entryId; return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.DOCUMENT_LIBRARY)) { long folderId = GetterUtil.getLong(doc.get("repositoryId")); String name = doc.get("path"); DLFileEntry fileEntry = dlFileEntryLocalService.getFileEntry(folderId, name); long classNameId = PortalUtil.getClassNameId(DLFileEntry.class.getName()); long classPK = fileEntry.getFileEntryId(); return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.IMAGE_GALLERY)) { long imageId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)); long classNameId = PortalUtil.getClassNameId(IGImage.class.getName()); long classPK = imageId; return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.JOURNAL)) { long groupId = GetterUtil.getLong(doc.get(Field.GROUP_ID)); String articleId = doc.get(Field.ENTRY_CLASS_PK); // double version = GetterUtil.getDouble(doc.get("version")); long articleResourcePrimKey = journalArticleResourceLocalService.getArticleResourcePrimKey(groupId, articleId);/*from www .j av a2 s . c o m*/ long classNameId = PortalUtil.getClassNameId(JournalArticle.class.getName()); long classPK = articleResourcePrimKey; return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) { long messageId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)); long classNameId = PortalUtil.getClassNameId(MBMessage.class.getName()); long classPK = messageId; return tagsAssetPersistence.findByC_C(classNameId, classPK); } else if (portletId.equals(PortletKeys.WIKI)) { long nodeId = GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)); String title = doc.get(Field.TITLE); long pageResourcePrimKey = wikiPageResourceLocalService.getPageResourcePrimKey(nodeId, title); long classNameId = PortalUtil.getClassNameId(WikiPage.class.getName()); long classPK = pageResourcePrimKey; return tagsAssetPersistence.findByC_C(classNameId, classPK); } return null; }
From source file:com.liferay.portlet.wiki.util.WikiIndexer.java
License:Open Source License
@Override protected Document doGetDocument(Object obj) throws Exception { WikiPage page = (WikiPage) obj;/*from w w w . j a v a 2 s. co m*/ Document document = getBaseModelDocument(PORTLET_ID, page); document.addUID(PORTLET_ID, page.getNodeId(), page.getTitle()); String content = HtmlUtil.extractText(WikiUtil.convert(page, null, null, null)); document.addText(Field.CONTENT, content); document.addKeyword(Field.NODE_ID, page.getNodeId()); document.addText(Field.TITLE, page.getTitle()); return document; }
From source file:com.liferay.portlet.wiki.util.WikiIndexer.java
License:Open Source License
@Override protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletURL portletURL) { String title = document.get(Field.TITLE); String content = snippet;//from w ww . java2s. c o m if (Validator.isNull(snippet)) { content = StringUtil.shorten(document.get(Field.CONTENT), 200); } String nodeId = document.get("nodeId"); portletURL.setParameter("struts_action", "/wiki/view"); portletURL.setParameter("nodeId", nodeId); portletURL.setParameter("title", title); return new Summary(title, content, portletURL); }
From source file:com.liferay.repository.external.ExtRepositoryAdapter.java
License:Open Source License
@Override public Hits search(SearchContext searchContext, Query query) throws SearchException { long startTime = System.currentTimeMillis(); List<ExtRepositorySearchResult<?>> extRepositorySearchResults = null; try {//w w w .j ava 2 s.com extRepositorySearchResults = _extRepository.search(searchContext, query, new ExtRepositoryQueryMapperImpl(this)); } catch (PortalException pe) { throw new SearchException("Unable to perform search", pe); } catch (SystemException se) { throw new SearchException("Unable to perform search", se); } QueryConfig queryConfig = searchContext.getQueryConfig(); List<Document> documents = new ArrayList<Document>(); List<String> snippets = new ArrayList<String>(); List<Float> scores = new ArrayList<Float>(); int total = 0; for (ExtRepositorySearchResult<?> extRepositorySearchResult : extRepositorySearchResults) { try { ExtRepositoryObjectAdapter<?> extRepositoryEntryAdapter = _toExtRepositoryObjectAdapter( ExtRepositoryObjectAdapterType.OBJECT, extRepositorySearchResult.getObject()); Document document = new DocumentImpl(); document.addKeyword(Field.ENTRY_CLASS_NAME, extRepositoryEntryAdapter.getModelClassName()); document.addKeyword(Field.ENTRY_CLASS_PK, extRepositoryEntryAdapter.getPrimaryKey()); document.addKeyword(Field.TITLE, extRepositoryEntryAdapter.getName()); documents.add(document); if (queryConfig.isScoreEnabled()) { scores.add(extRepositorySearchResult.getScore()); } else { scores.add(1.0F); } snippets.add(extRepositorySearchResult.getSnippet()); total++; } catch (SystemException se) { if (_log.isWarnEnabled()) { _log.warn("Invalid entry returned from search", se); } } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Invalid entry returned from search", pe); } } } float searchTime = (float) (System.currentTimeMillis() - startTime) / Time.SECOND; Hits hits = new HitsImpl(); hits.setDocs(documents.toArray(new Document[documents.size()])); hits.setLength(total); hits.setQueryTerms(new String[0]); hits.setScores(ArrayUtil.toFloatArray(scores)); hits.setSearchTime(searchTime); hits.setSnippets(snippets.toArray(new String[snippets.size()])); hits.setStart(startTime); return hits; }
From source file:com.liferay.trash.internal.search.TrashIndexer.java
License:Open Source License
@Override public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter, SearchContext searchContext) throws Exception { if (searchContext.getAttributes() == null) { return;/*from www . java 2s. c om*/ } addSearchLocalizedTerm(searchQuery, searchContext, Field.CONTENT, true); addSearchLocalizedTerm(searchQuery, searchContext, Field.DESCRIPTION, true); addSearchTerm(searchQuery, searchContext, Field.REMOVED_BY_USER_NAME, true); addSearchLocalizedTerm(searchQuery, searchContext, Field.TITLE, true); addSearchTerm(searchQuery, searchContext, Field.TYPE, false); addSearchTerm(searchQuery, searchContext, Field.USER_NAME, true); }
From source file:com.liferay.wiki.search.test.WikiPageTitleSearcherTest.java
License:Open Source License
protected void assertSearchTitle(final String keywords, final String title) throws Exception { IdempotentRetryAssert.retryAssert(3, TimeUnit.SECONDS, new Callable<Void>() { @Override/*from www .j av a 2 s . c om*/ public Void call() throws Exception { Indexer<?> indexer = WikiPageTitleSearcher.getInstance(); _searchContext.setKeywords(StringUtil.toLowerCase(keywords)); Hits hits = indexer.search(_searchContext); for (Document document : hits.getDocs()) { Assert.assertEquals(title, document.get(Field.TITLE)); } return null; } }); }
From source file:com.liferay.wiki.search.WikiNodeIndexer.java
License:Open Source License
@Override protected Document doGetDocument(WikiNode wikiNode) throws Exception { Document document = getBaseModelDocument(CLASS_NAME, wikiNode); document.addText(Field.DESCRIPTION, wikiNode.getDescription()); String title = wikiNode.getName(); if (wikiNode.isInTrash()) { title = TrashUtil.getOriginalTitle(title); }/*from ww w . j a v a 2 s . c o m*/ document.addText(Field.TITLE, title); return document; }
From source file:com.liferay.wiki.search.WikiPageIndexer.java
License:Open Source License
public WikiPageIndexer() { setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.COMPANY_ID, Field.CONTENT, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.MODIFIED_DATE, Field.SCOPE_GROUP_ID, Field.TITLE, Field.UID);//from w w w . j a va 2 s . c o m setFilterSearch(true); setPermissionAware(true); }