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.bookmarks.search.BookmarksFolderIndexer.java

License:Open Source License

public BookmarksFolderIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.TITLE,
            Field.UID);//from  w  ww .  j  av  a 2  s  .c  o  m
    setFilterSearch(true);
    setPermissionAware(true);
}

From source file:com.liferay.bookmarks.search.BookmarksFolderIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(BookmarksFolder bookmarksFolder) throws Exception {

    if (_log.isDebugEnabled()) {
        _log.debug("Indexing folder " + bookmarksFolder);
    }/*from www  . ja  v  a 2s. c  o m*/

    Document document = getBaseModelDocument(CLASS_NAME, bookmarksFolder);

    document.addText(Field.DESCRIPTION, bookmarksFolder.getDescription());
    document.addKeyword(Field.FOLDER_ID, bookmarksFolder.getParentFolderId());
    document.addText(Field.TITLE, bookmarksFolder.getName());
    document.addKeyword(Field.TREE_PATH, StringUtil.split(bookmarksFolder.getTreePath(), CharPool.SLASH));

    if (_log.isDebugEnabled()) {
        _log.debug("Document " + bookmarksFolder + " indexed successfully");
    }

    return document;
}

From source file:com.liferay.bookmarks.search.BookmarksFolderIndexer.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.DESCRIPTION);

    summary.setMaxContentLength(200);//from  w w  w .  j av a  2 s.co m

    return summary;
}

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

License:Open Source License

@Test
public void testSearchAndVerifyDocs() throws Exception {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_group.getGroupId());

    BookmarksFolder folder = BookmarksTestUtil.addFolder(_group.getGroupId(), RandomTestUtil.randomString());

    BookmarksEntry entry = BookmarksTestUtil.addEntry(folder.getFolderId(), true, serviceContext);

    SearchContext searchContext = BookmarksTestUtil.getSearchContext(entry.getCompanyId(), entry.getGroupId(),
            entry.getFolderId(), "test");

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

    Hits hits = indexer.search(searchContext);

    Assert.assertEquals(1, hits.getLength());

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

    for (Document doc : results) {
        Assert.assertEquals(entry.getCompanyId(), GetterUtil.getLong(doc.get(Field.COMPANY_ID)));
        Assert.assertEquals(BookmarksEntry.class.getName(), doc.get(Field.ENTRY_CLASS_NAME));
        Assert.assertEquals(entry.getEntryId(), GetterUtil.getLong(doc.get(Field.ENTRY_CLASS_PK)));
        AssertUtils.assertEqualsIgnoreCase(entry.getName(), doc.get(Field.TITLE));
        Assert.assertEquals(entry.getUrl(), doc.get(Field.URL));
    }//from w w  w.j  a v a 2s .co  m
}

From source file:com.liferay.calendar.search.CalendarBookingIndexer.java

License:Open Source License

public CalendarBookingIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.DESCRIPTION, Field.TITLE);
    setPermissionAware(true);//  ww  w . j a v  a  2s  . c  om
}

From source file:com.liferay.calendar.search.CalendarBookingIndexer.java

License:Open Source License

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

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

From source file:com.liferay.calendar.search.CalendarBookingIndexer.java

License:Open Source License

@Override
protected Document doGetDocument(CalendarBooking calendarBooking) throws Exception {

    Document document = getBaseModelDocument(CLASS_NAME, calendarBooking);

    document.addKeyword(Field.CLASS_NAME_ID, _classNameLocalService.getClassNameId(Calendar.class));
    document.addKeyword(Field.CLASS_PK, calendarBooking.getCalendarId());

    Locale defaultLocale = LocaleUtil.getSiteDefault();

    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);

    String[] descriptionLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getDescription());

    for (String descriptionLanguageId : descriptionLanguageIds) {
        String description = calendarBooking.getDescription(descriptionLanguageId);

        document.addText(LocalizationUtil.getLocalizedName(Field.DESCRIPTION, descriptionLanguageId),
                description);// w  ww  .  j  a v a2 s . co  m
    }

    document.addKeyword(Field.RELATED_ENTRY, true);

    String[] titleLanguageIds = getLanguageIds(defaultLanguageId, calendarBooking.getTitle());

    for (String titleLanguageId : titleLanguageIds) {
        String title = calendarBooking.getTitle(titleLanguageId);

        document.addText(LocalizationUtil.getLocalizedName(Field.TITLE, titleLanguageId), title);
    }

    document.addKeyword(Field.VIEW_ACTION_ID, CalendarActionKeys.VIEW_BOOKING_DETAILS);

    String calendarBookingId = String.valueOf(calendarBooking.getCalendarBookingId());

    if (calendarBooking.isInTrash()) {
        calendarBookingId = TrashUtil.getOriginalTitle(calendarBookingId);
    }

    document.addKeyword("calendarBookingId", calendarBookingId);

    document.addText("defaultLanguageId", defaultLanguageId);
    document.addNumber("endTime", calendarBooking.getEndTime());
    document.addText("location", calendarBooking.getLocation());
    document.addNumber("startTime", calendarBooking.getStartTime());

    return document;
}

From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java

License:Open Source License

protected void populateTitle(String title, Map<String, String> map) {
    map.put(Field.TITLE + "_en_US", title);

    map.put("localized_title", title);
    map.put("localized_title_ca_ES", title);
    map.put("localized_title_ca_ES_sortable", title);
    map.put("localized_title_de_DE", title);
    map.put("localized_title_de_DE_sortable", title);
    map.put("localized_title_en_US", title);
    map.put("localized_title_en_US_sortable", title);
    map.put("localized_title_es_ES", title);
    map.put("localized_title_es_ES_sortable", title);
    map.put("localized_title_fi_FI", title);
    map.put("localized_title_fi_FI_sortable", title);
    map.put("localized_title_fr_FR", title);
    map.put("localized_title_fr_FR_sortable", title);
    map.put("localized_title_iw_IL", title);
    map.put("localized_title_iw_IL_sortable", title);
    map.put("localized_title_ja_JP", title);
    map.put("localized_title_ja_JP_sortable", title);
    map.put("localized_title_nl_NL", title);
    map.put("localized_title_nl_NL_sortable", title);
    map.put("localized_title_pt_BR", title);
    map.put("localized_title_pt_BR_sortable", title);
    map.put("localized_title_zh_CN", title);
    map.put("localized_title_zh_CN_sortable", title);
}

From source file:com.liferay.calendar.search.test.CalendarBookingIndexerIndexedFieldsTest.java

License:Open Source License

protected void populateTranslatedTitle(String title, Map<String, String> map) {

    map.put(Field.TITLE + "_hu_HU", title);

    map.put("localized_title_hu_HU", title);
    map.put("localized_title_hu_HU_sortable", title);
}

From source file:com.liferay.calendar.util.CalendarBookingIndexer.java

License:Open Source License

public CalendarBookingIndexer() {
    setDefaultSelectedFieldNames(Field.COMPANY_ID, Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
    setDefaultSelectedLocalizedFieldNames(Field.DESCRIPTION, Field.TITLE);
}