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

    • Fix Priority:
      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
      ee-6.2.x@ab4b0f26eaea5717d166d6df7d679e283c796af6

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                zsolt.olah Zsolt Oláh (Inactive)
                Reporter:
                zsolt.olah Zsolt Oláh (Inactive)
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  3 years, 33 weeks, 5 days ago

                  Packages

                  Version Package
                  7.0.0 Alpha 1