Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
    • Fix Version/s: 6.1.30 EE GA3, 6.2.0 CE M6
    • Component/s: Search Infrastructure
    • Labels:
    • Environment:
      Tomcat 7 + Oracle 11g. Portal EE 6.1.x GIT ID: a53e1bfe45d67ca0e53aac060a8af0d0a1d554dd.
      Tomcat 7 + Oracle 11g. Portal CE 6.2.x GIT ID: 92946415c75e5c4a04b8c450b511f078e6b42be5.
    • Branch Version/s:
      6.1.x
    • Backported to Branch:
      Committed
    • Story Points:
      5
    • Fix Priority:
      4

      Description

      Background

      As the order of retrieved rows of a SELECT statement without an ORDER BY clause is completely arbitrary, the following piece of code in JournalArticleIndexer might index old versions instead of new ones.

      ActionableDynamicQuery actionableDynamicQuery =
      	new JournalArticleActionableDynamicQuery() {
      
      	@Override
      	protected void addCriteria(DynamicQuery dynamicQuery) {
      		Junction junction = RestrictionsFactoryUtil.disjunction();
      
      		Junction approvedArticlesJunction =
      			RestrictionsFactoryUtil.conjunction();
      
      		Property statusProperty = PropertyFactoryUtil.forName("status");
      
      		approvedArticlesJunction.add(
      			statusProperty.eq(WorkflowConstants.STATUS_APPROVED));
      
      		junction.add(approvedArticlesJunction);
      
      		Junction draftArticlesJunction =
      			RestrictionsFactoryUtil.conjunction();
      
      		Property versionProperty = PropertyFactoryUtil.forName(
      			"version");
      
      		draftArticlesJunction.add(
      			versionProperty.eq(
      				JournalArticleConstants.VERSION_DEFAULT));
      
      		draftArticlesJunction.add(
      			statusProperty.eq(WorkflowConstants.STATUS_DRAFT));
      
      		junction.add(draftArticlesJunction);
      
      		dynamicQuery.add(junction);
      
      		Property indexableProperty = PropertyFactoryUtil.forName(
      			"indexable");
      
      		dynamicQuery.add(indexableProperty.eq(true));
      	}
      
      	@Override
      	protected void performAction(Object object)
      		throws PortalException, SystemException {
      
      		JournalArticle article = (JournalArticle)object;
      
      		if (article.isApproved()) {
      			JournalArticle latestArticle =
      				JournalArticleLocalServiceUtil.getLatestArticle(
      					article.getResourcePrimKey(),
      					WorkflowConstants.STATUS_APPROVED);
      
      			if (!latestArticle.isIndexable()) {
      				return;
      			}
      		}
      
      		Document document = getDocument(article);
      
      		documents.add(document);
      	}
      
      };
      

      Steps to reproduce

      1) Create a Web Content with title "WC1" and publish it a few times in order to create more than one version of it.
      2) Even tough the row order is completely arbitrary, in small quantities we can reverse it for the sake of testability.

      CREATE TABLE JournalArticle_tmp AS
      SELECT * FROM JournalArticle;
      
      TRUNCATE TABLE JournalArticle;
      
      INSERT INTO JournalArticle
      SELECT * FROM JournalArticle_tmp ORDER BY id_ DESC;
      COMMIT; -- Commiting here retained only for readability; DDL statements perform commit implicitely.
      
      -- Mark this index unusable to force the optimizer to generate such an
      -- execution plan which is going to retrieve the rows in reverse order.
      ALTER INDEX IX_E82F322B UNUSABLE;
      

      3) Do a full reindex.

      4) Look into the search index with Luke (https://luke.googlecode.com/files/lukeall-3.5.0.jar).

      $ java -jar /path/to/lukeall-3.5.0.jar
      
      • Point Luke to the index direcotory of Liferay.
        Example Path: /home/lcsontos/liferay/instances/lportal-trunk/data/lucene
      • Tick Open in Read-Only mode.

      5) Search for "title:wc1" (with lowercase) and seek field version.

      • Select the Search tab.
      • Put search query into field Enter the search expression here.
      • Click Search.

      What you should see here is that the current value of version of the found document is "1.0" (or the lowest if you previously deleted "1.0").

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mark.jin Mark Jin (Inactive)
                Reporter:
                laszlo.csontos Laszlo Csontos (Inactive)
                Participants of an Issue:
                Recent user:
                Esther Sanz
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 6 weeks ago

                  Subcomponents