[infinispan-issues] [JBoss JIRA] (ISPN-5706) Execution of a Hibrid Query returns incorrect results, when the filter condition fails(match() returns false) for at least some of the results returned by the lucene query execution, before reaching any other successful results(which satisfies the filter)

Prashanth Reddy (JIRA) issues at jboss.org
Wed Aug 26 13:39:43 EDT 2015


Prashanth Reddy created ISPN-5706:
-------------------------------------

             Summary: Execution of a Hibrid Query returns incorrect results, when the filter condition fails(match() returns false) for at least some of the results returned by the lucene query execution, before reaching any other successful results(which satisfies the filter)
                 Key: ISPN-5706
                 URL: https://issues.jboss.org/browse/ISPN-5706
             Project: Infinispan
          Issue Type: Bug
          Components: Embedded Querying
    Affects Versions: 8.0.0.Beta3
            Reporter: Prashanth Reddy
         Attachments: HybridQuery.diff

The hibrid query, mentioned below produces partial or zero results(depending on the data), upon execution.

SELECT p.ID, p.NAME FROM com.testapp.Person p WHERE p.IS_ACTIVE=1 AND p.ID>1000 and p.ID<10000


For the data,

ID | NAME | CITY | IS_ACTIVE
-------------------
2001 person1 city1 0
2002 person1 city1 1
2003 person1 city1 1 
2004 person1 city1 0
2005 person1 city2 1
2006 person1 city2 1
2007 person1 city3 0
2008 person1 city3 1

Indexed fields: ID, NAME, CITY
Non-indexed fields: IS_ACTIVE


Query execution returned 0 number of rows, whereas expected result count is 8.

Root cause for the problem is very trivial, and the details are as follows,

As we know, hibrid query execution involves, 
* Execution of lucene query that is constructed based on boole shannon expansion
* Applying filter on the results obtained from above operation, in order to cover the conditions that deals with non-indexed fields

In the second step, there is a mismatch between the representation of filter operation return status and the way end of the result list is detected at the outer layer.

As per the current implementation, filter operation returns null, if the filter condition is not satisfied. But, the same is also used for determining whether there are any further results to be retrieved, which is causing the actual problem.


Following changes can resolve the problem,

file: infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java
diff:

Index: infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java
===================================================================
--- infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java	(revision -----)
+++ infinispan-8.0.0.Beta3/query/src/main/java/org/infinispan/query/dsl/embedded/impl/HybridQuery.java	(working copy)
@@ -70,12 +70,15 @@
 
          private void update() {
             if (!isReady) {
-               if (it.hasNext()) {
-                  Object next = it.next();
-                  nextResult = objectFilter.filter(next);
-               } else {
-                  nextResult = null;
-               }
+                do {
+                    if (it.hasNext()) {
+                        Object next = it.next();
+                        nextResult = objectFilter.filter(next);
+                    } else {
+                        nextResult = null;
+                        break;
+                    }
+                } while (nextResult == null);
                isReady = true;
             }
          }





--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the infinispan-issues mailing list