Example usage for com.liferay.portal.kernel.search Field TITLE

List of usage examples for com.liferay.portal.kernel.search Field TITLE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.search Field TITLE.

Prototype

String TITLE

To view the source code for com.liferay.portal.kernel.search Field TITLE.

Click Source Link

Usage

From source file:com.liferay.message.boards.internal.search.MBMessageIndexer.java

License:Open Source License

@Override
protected Summary doGetSummary(Document document, Locale locale, String snippet, PortletRequest portletRequest,
        PortletResponse portletResponse) {

    Summary summary = createSummary(document, Field.TITLE, Field.CONTENT);

    summary.setMaxContentLength(200);/*from   ww  w.j  av  a  2  s . c  o  m*/

    return summary;
}

From source file:com.liferay.polls.internal.search.PollsQuestionIndexer.java

License:Open Source License

public PollsQuestionIndexer() {
    setDefaultSelectedFieldNames(Field.ASSET_TAG_NAMES, Field.CREATE_DATE, Field.COMPANY_ID, Field.DESCRIPTION,
            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.GROUP_ID, Field.SCOPE_GROUP_ID, Field.TITLE,
            Field.UID);//from   w  w w . j  a v  a  2s  .  c  om
    setFilterSearch(true);
}

From source file:com.liferay.polls.internal.search.PollsQuestionIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(PollsQuestion pollsQuestion) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, pollsQuestion);

    document.addDateSortable(Field.CREATE_DATE, pollsQuestion.getCreateDate());
    document.addText(Field.DESCRIPTION, getDescriptionField(pollsQuestion));
    document.addText(Field.TITLE, getTitleField(pollsQuestion));

    return document;
}

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

@Override
public Hits search(long companyId, long[] groupIds, long userId, String className, String userName,
        String title, String description, String assetCategoryIds, String assetTagNames, int status,
        boolean andSearch, int start, int end) throws SystemException {
    try {//from   w w  w .j  ava 2s  . c o  m
        SearchContext searchContext = new SearchContext();

        Facet assetEntriesFacet = new AssetEntriesFacet(searchContext);

        assetEntriesFacet.setStatic(true);

        searchContext.addFacet(assetEntriesFacet);

        Facet scopeFacet = new ScopeFacet(searchContext);

        scopeFacet.setStatic(true);

        searchContext.addFacet(scopeFacet);

        searchContext.setAndSearch(andSearch);
        searchContext.setAssetCategoryIds(StringUtil.split(assetCategoryIds, 0L));
        searchContext.setAssetTagNames(StringUtil.split(assetTagNames));
        searchContext.setAttribute(Field.DESCRIPTION, description);
        searchContext.setAttribute(Field.TITLE, title);
        searchContext.setAttribute(Field.USER_NAME, userName);
        searchContext.setAttribute("paginationType", "regular");
        searchContext.setAttribute("status", status);
        searchContext.setCompanyId(companyId);
        searchContext.setEnd(end);
        searchContext.setEntryClassNames(getClassNames(companyId, className));
        searchContext.setGroupIds(groupIds);

        QueryConfig queryConfig = new QueryConfig();

        queryConfig.setHighlightEnabled(false);
        queryConfig.setScoreEnabled(false);

        searchContext.setQueryConfig(queryConfig);

        searchContext.setStart(start);
        searchContext.setUserId(userId);

        Indexer indexer = FacetedSearcher.getInstance();

        return indexer.search(searchContext);
    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:com.liferay.portlet.asset.service.impl.AssetEntryLocalServiceImpl.java

License:Open Source License

protected AssetEntry getEntry(Document document) throws PortalException, SystemException {
    String portletId = GetterUtil.getString(document.get(Field.PORTLET_ID));

    if (portletId.equals(PortletKeys.BLOGS)) {
        long entryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        long classNameId = PortalUtil.getClassNameId(BlogsEntry.class.getName());
        long classPK = entryId;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    } else if (portletId.equals(PortletKeys.BOOKMARKS)) {
        long entryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        long classNameId = PortalUtil.getClassNameId(BookmarksEntry.class.getName());
        long classPK = entryId;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    } else if (portletId.equals(PortletKeys.DOCUMENT_LIBRARY)) {
        long fileEntryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        long classNameId = PortalUtil.getClassNameId(DLFileEntry.class.getName());
        long classPK = fileEntryId;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    } else if (portletId.equals(PortletKeys.JOURNAL)) {
        long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
        String articleId = document.get("articleId");
        //double version = GetterUtil.getDouble(document.get("version"));

        long articleResourcePrimKey = journalArticleResourceLocalService.getArticleResourcePrimKey(groupId,
                articleId);/*  www  .ja v  a2s.c  om*/

        long classNameId = PortalUtil.getClassNameId(JournalArticle.class.getName());
        long classPK = articleResourcePrimKey;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    } else if (portletId.equals(PortletKeys.MESSAGE_BOARDS)) {
        long messageId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));

        long classNameId = PortalUtil.getClassNameId(MBMessage.class.getName());
        long classPK = messageId;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    } else if (portletId.equals(PortletKeys.WIKI)) {
        long nodeId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK));
        String title = document.get(Field.TITLE);

        long pageResourcePrimKey = wikiPageResourceLocalService.getPageResourcePrimKey(nodeId, title);

        long classNameId = PortalUtil.getClassNameId(WikiPage.class.getName());
        long classPK = pageResourcePrimKey;

        return assetEntryPersistence.findByC_C(classNameId, classPK);
    }

    return null;
}

From source file:com.liferay.portlet.assetpublisher.util.AssetIndexer.java

License:Open Source License

@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, SearchContext searchContext) throws Exception {

    if (searchContext.getAttributes() == null) {
        return;//  www  .  j  a  va2s. c o  m
    }

    addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
    addSearchTerm(searchQuery, searchContext, Field.TITLE, false);
    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);
}

From source file:com.liferay.portlet.blogs.util.BlogsIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    BlogsEntry entry = (BlogsEntry) obj;

    Document document = getBaseModelDocument(PORTLET_ID, entry);

    document.addText(Field.CONTENT, HtmlUtil.extractText(entry.getContent()));
    document.addDate(Field.MODIFIED_DATE, entry.getDisplayDate());
    document.addText(Field.TITLE, entry.getTitle());

    return document;
}

From source file:com.liferay.portlet.blogs.util.BlogsIndexer.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  . j  av a 2 s .  c o m*/

    if (Validator.isNull(snippet)) {
        content = StringUtil.shorten(document.get(Field.CONTENT), 200);
    }

    String entryId = document.get(Field.ENTRY_CLASS_PK);

    portletURL.setParameter("struts_action", "/blogs/view_entry");
    portletURL.setParameter("entryId", entryId);

    return new Summary(title, content, portletURL);
}

From source file:com.liferay.portlet.bookmarks.service.BookmarksFolderServiceTest.java

License:Open Source License

public void testSearch() throws Exception {
    BookmarksEntry entry = addEntry();/*from  w w  w  .  java 2s  .  co m*/

    Thread.sleep(1000);

    long companyId = entry.getCompanyId();
    long groupId = entry.getFolder().getGroupId();
    long folderId = entry.getFolderId();
    String keywords = "test";

    SearchContext searchContext = new SearchContext();

    searchContext.setCompanyId(companyId);
    searchContext.setFolderIds(new long[] { folderId });
    searchContext.setGroupIds(new long[] { groupId });
    searchContext.setKeywords(keywords);

    QueryConfig queryConfig = new QueryConfig();

    queryConfig.setHighlightEnabled(false);
    queryConfig.setScoreEnabled(false);

    searchContext.setQueryConfig(queryConfig);

    Indexer indexer = IndexerRegistryUtil.getIndexer(BookmarksEntry.class);

    Hits hits = indexer.search(searchContext);

    assertEquals(1, hits.getLength());

    List<Document> results = hits.toList();

    for (Document doc : results) {
        assertEquals(companyId, GetterUtil.getLong(doc.get(Field.COMPANY_ID)));

        assertEquals(groupId, GetterUtil.getLong(doc.get(Field.GROUP_ID)));

        assertEqualsIgnoreCase(entry.getName(), doc.get(Field.TITLE));
        assertEquals(entry.getUrl(), doc.get(Field.URL));
        assertEqualsIgnoreCase(entry.getDescription(), doc.get(Field.DESCRIPTION));

        assertEquals(folderId, GetterUtil.getLong(doc.get("folderId")));
        assertEquals(entry.getEntryId(), GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)));
    }

    BookmarksFolderLocalServiceUtil.deleteFolder(folderId);

    Thread.sleep(1000);

    hits = indexer.search(searchContext);

    Query query = hits.getQuery();

    assertEquals(query.toString(), 0, hits.getLength());

    addEntry();
    addEntry();
    addEntry();
    addEntry();

    Thread.sleep(1000);

    searchContext.setEnd(3);
    searchContext.setFolderIds(null);
    searchContext.setStart(1);

    hits = indexer.search(searchContext);

    assertEquals(4, hits.getLength());
    assertEquals(2, hits.getDocs().length);
}

From source file:com.liferay.portlet.bookmarks.util.BookmarksIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(Object obj) throws Exception {
    BookmarksEntry entry = (BookmarksEntry) obj;

    Document document = getBaseModelDocument(PORTLET_ID, entry);

    document.addText(Field.DESCRIPTION, entry.getDescription());
    document.addKeyword(Field.FOLDER_ID, entry.getFolderId());
    document.addText(Field.TITLE, entry.getName());
    document.addText(Field.URL, entry.getUrl());

    return document;
}