Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-62812

In the search results, only the first 200 characters should be displayed from a Web Content

Details

    • 2

    Description

      Reproduction steps:
      1. Click on Admin -> Content
      2. Create a Structure with a HTML field
      3. Create a Template for the Structure (make sure the template has html.getData())
      4. Create a Web Content from the structure, for example the following text:

      Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

      5. Add the Search portlet to a page
      6. Search for the created Web Content

      Experienced behavior: As you can see the whole Web Content is displayed

      Expected behavior: The first 200 characters should be displayed, just as in case of basic web contents

      The problem is that

      com.liferay.portlet.journal.util.JournalArticleIndexer.getDDMContentSummary(Document, Locale)
      	protected String getDDMContentSummary(
      		Document document, Locale snippetLocale) {
      
      		String content = StringPool.BLANK;
      
      		try {
      			long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
      			String articleId = document.get("articleId");
      			double version = GetterUtil.getDouble(document.get(Field.VERSION));
      
      			JournalArticle article =
      				JournalArticleLocalServiceUtil.fetchArticle(
      					groupId, articleId, version);
      
      			if (article == null) {
      				return content;
      			}
      
      			JournalArticleDisplay articleDisplay =
      				JournalArticleLocalServiceUtil.getArticleDisplay(
      					article, null, Constants.VIEW,
      					LocaleUtil.toLanguageId(snippetLocale), 1, null, null);
      
      			content = HtmlUtil.escape(articleDisplay.getDescription());
      			content = HtmlUtil.replaceNewLine(content);
      
      			if (Validator.isNull(content)) {
      				content = HtmlUtil.extractText(articleDisplay.getContent());
      			}
      		}
      		catch (Exception e) {
      			if (_log.isDebugEnabled()) {
      				_log.debug(e, e);
      			}
      		}
      
      		return content;
      	}
      

      doesn't set a limit when generating the Summary, while

      com.liferay.portlet.journal.util.JournalArticleIndexer.getBasicContentSummary(Document, Locale)
      	protected String getBasicContentSummary(
      		Document document, Locale snippetLocale) {
      
      		String prefix = Field.SNIPPET + StringPool.UNDERLINE;
      
      		String content = document.get(
      			snippetLocale, prefix + Field.DESCRIPTION, prefix + Field.CONTENT);
      
      		if (Validator.isBlank(content)) {
      			content = document.get(
      				snippetLocale, Field.DESCRIPTION, Field.CONTENT);
      		}
      
      		if (content.length() > 200) {
      			content = StringUtil.shorten(content, 200);
      		}
      
      		return content;
      	}
      

      does.
      It's maximum 200 characters of the matching snippet. Not 192.
      Verified on
      [email protected]

      Attachments

        Issue Links

          Activity

            People

              zsolt.olah Zsolt Oláh (Inactive)
              zsolt.olah Zsolt Oláh (Inactive)
              Kiyoshi Lee Kiyoshi Lee
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                7 years, 17 weeks, 5 days ago

                Packages

                  Version Package
                  7.0.0 Alpha 1