nit0906 commented on code in PR #671:
URL: https://github.com/apache/jackrabbit-oak/pull/671#discussion_r952106899


##########
oak-search/src/test/java/org/apache/jackrabbit/oak/plugins/index/FullTextIndexCommonTest.java:
##########
@@ -112,6 +113,67 @@ public void testFullTextTermWithUnescapedBraces() throws 
Exception {
         }
     }
 
+    @Test
+    public void pathTransformationsWithNoPathRestrictions() throws Exception {
+        Tree test = setup();
+        test.addChild("a").addChild("j:c").setProperty("analyzed_field", 
"bar");
+        test.addChild("b").setProperty("analyzed_field", "bar");
+        
test.addChild("c").addChild("d").addChild("j:c").setProperty("analyzed_field", 
"bar");
+
+        root.commit();
+
+        assertEventually(() -> {
+            assertQuery("//*[j:c/@analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a", "/test/c/d"));
+            assertQuery("//*[d/*/@analyzed_field = 'bar']", XPATH, 
Collections.singletonList("/test/c"));
+        });
+    }
+
+    @Test
+    public void pathTransformationsWithPathRestrictions() throws Exception {
+        Tree test = setup();
+
+        test.addChild("a").addChild("j:c").setProperty("analyzed_field", 
"bar");
+        test.addChild("b").setProperty("analyzed_field", "bar");
+        
test.addChild("c").addChild("d").addChild("j:c").setProperty("analyzed_field", 
"bar");
+        test.addChild("e").addChild("temp:c").setProperty("analyzed_field", 
"bar");
+        
test.addChild("f").addChild("d").addChild("temp:c").setProperty("analyzed_field",
 "bar");
+        
test.addChild("g").addChild("e").addChild("temp:c").setProperty("analyzed_field",
 "bar");
+
+
+        Tree temp = root.getTree("/").addChild("tmp");
+
+        temp.addChild("a").addChild("j:c").setProperty("analyzed_field", 
"bar");
+        temp.addChild("b").setProperty("analyzed_field", "bar");
+        
temp.addChild("c").addChild("d").addChild("j:c").setProperty("analyzed_field", 
"bar");
+        root.commit();
+
+        assertEventually(() -> {
+            // ALL CHILDREN
+            assertQuery("/jcr:root/test//*[j:c/analyzed_field = 'bar']", 
XPATH, Arrays.asList("/test/a", "/test/c/d"));
+            assertQuery("/jcr:root/test//*[*/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a", "/test/c/d", "/test/e", "/test/f/d", "/test/g/e"));
+            assertQuery("/jcr:root/test//*[d/*/analyzed_field = 'bar']", 
XPATH, Arrays.asList("/test/c", "/test/f"));
+            assertQuery("/jcr:root/test//*[analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a/j:c","/test/b","/test/c/d/j:c",
+                    "/test/e/temp:c", "/test/f/d/temp:c","/test/g/e/temp:c"));
+
+            // DIRECT CHILDREN
+            assertQuery("/jcr:root/test/*[j:c/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a"));
+            assertQuery("/jcr:root/test/*[*/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a", "/test/e"));
+            assertQuery("/jcr:root/test/*[d/*/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/c", "/test/f"));
+            assertQuery("/jcr:root/test/*[analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/b"));
+
+            // EXACT
+            assertQuery("/jcr:root/test/a[j:c/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a"));
+            assertQuery("/jcr:root/test/a[*/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a"));
+            assertQuery("/jcr:root/test/c[d/*/analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/c"));
+            assertQuery("/jcr:root/test/a/j:c[analyzed_field = 'bar']", XPATH, 
Arrays.asList("/test/a/j:c"));
+
+            // TODO : We don't have assertions for PARENT path filter here.

Review Comment:
   @thomasmueller  thanks for the help with query. I added the new test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to