Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-20569

Fix ElasticSearch Fetch of List Property Values

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 8.3
    • Fix Version/s: None
    • Component/s: Elasticsearch
    • Tags:
    • Backlog priority:
      800
    • Sprint:
      nxBD 8.4.6

      Description

      Fetching query results from ElasticSearch that contain List property values is broken. In order to meet performance requirements, we have specific queries that must fetch from ElasticSearch rather than VCS.

      In order to reproduce the problem, apply the following patch to test class TestCompareCoreWithES.java.

      diff --git a/nuxeo-features/nuxeo-elasticsearch/nuxeo-elasticsearch-core/src/test/java/org/nuxeo/elasticsearch/test/nxql/TestCompareCoreWithES.java b/nuxeo-features/nuxeo-elasticsearch
      /nuxeo-elasticsearch-core/src/test/java/org/nuxeo/elasticsearch/test/nxql/TestCompareCoreWithES.java                                                                                    
      index 1ff2360..42636a5 100644                                                                                                                                                           
      --- a/nuxeo-features/nuxeo-elasticsearch/nuxeo-elasticsearch-core/src/test/java/org/nuxeo/elasticsearch/test/nxql/TestCompareCoreWithES.java
      +++ b/nuxeo-features/nuxeo-elasticsearch/nuxeo-elasticsearch-core/src/test/java/org/nuxeo/elasticsearch/test/nxql/TestCompareCoreWithES.java
      @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit;
       
       import javax.inject.Inject;
       
      +import org.apache.commons.lang.ArrayUtils;
       import org.junit.After;
       import org.junit.Assert;
       import org.junit.Before;
      @@ -77,6 +78,8 @@ public class TestCompareCoreWithES {
                   doc.setPropertyValue("dc:title", "File" + i);
                   doc.setPropertyValue("dc:nature", "Nature" + i);
                   doc.setPropertyValue("dc:rights", "Rights" + i % 2);
      +            doc.setPropertyValue("dc:subjects",
      +                    (i % 2 == 0) ? new String[] {"Subjects1"} : new String[] {"Subjects1", "Subjects2"});
                   doc = session.createDocument(doc);
               }
               for (int i = 5; i < 10; i++) {
      @@ -135,6 +138,9 @@ public class TestCompareCoreWithES {
                       nameOrTitle = doc.getTitle();
                   }
                   sb.append(nameOrTitle);
      +            sb.append("[" + doc.getPropertyValue("dc:nature") + "]");
      +            sb.append("[" + doc.getPropertyValue("dc:rights") + "]");
      +            sb.append("[" + ArrayUtils.toString(doc.getPropertyValue("dc:subjects")) + "]");
                   sb.append(",");
               }
               return sb.toString();
      @@ -153,16 +159,22 @@ public class TestCompareCoreWithES {
           protected void compareESAndCore(String nxql) throws Exception {
       
               DocumentModelList coreResult = session.query(nxql);
      -        DocumentModelList esResult = ess.query(new NxQueryBuilder(session).nxql(nxql).limit(20));
      -        try {
      -            assertSameDocumentLists(coreResult, esResult);
      -        } catch (AssertionError e) {
      -            System.out.println("Error while executing " + nxql);
      -            System.out.println("Core result : ");
      -            dump(coreResult);
      -            System.out.println("elasticsearch result : ");
      -            dump(esResult);
      -            throw e;
      +        NxQueryBuilder nxQueryBuilder = new NxQueryBuilder(session).nxql(nxql).limit(20);
      +        for (int i = 0; i < 2; i++) {
      +            if (i == 1) {
      +                nxQueryBuilder = nxQueryBuilder.fetchFromElasticsearch();
      +            }
      +            DocumentModelList esResult = ess.query(nxQueryBuilder);
      +            try {
      +                assertSameDocumentLists(coreResult, esResult);
      +            } catch (AssertionError e) {
      +                System.out.println("Error while executing " + nxql);
      +                System.out.println("Core result : ");
      +                dump(coreResult);
      +                System.out.println("elasticsearch result : ");
      +                dump(esResult);
      +                throw e;
      +            }
               }
           }
      
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 minute
                  1m