nit0906 commented on a change in pull request #424:
URL: https://github.com/apache/jackrabbit-oak/pull/424#discussion_r756755310
##########
File path:
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/FulltextIndexConstants.java
##########
@@ -401,4 +401,11 @@ public static IndexingMode from(String indexingMode) {
* cost). The value is: nodes, the path. For properties, the path of the
node, then '@' property.
*/
String USE_IF_EXISTS = "useIfExists";
+
+ /*
+ When set to true for any particular property in an index, queries would
support leading wild cards in searches.
+ This is supported in lucene implementation by default, this configuration
is primarily meant for elastic index
+ and would be NOOP in lucene index definitions.
+ */
Review comment:
done
##########
File path:
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticFullTextAsyncTest.java
##########
@@ -70,6 +71,62 @@ public void fullTextQuery() throws Exception {
});
}
+ @Test
+ public void fullTextQueryTestAllowLeadingWildcards() throws Exception {
+ IndexDefinitionBuilder builder = createIndex("propa");
+ builder.async("async");
+
builder.indexRule("nt:base").property("propa").analyzed().allowLeadingWildcard();
+
+ String indexId = UUID.randomUUID().toString();
+ setIndex(indexId, builder);
+ root.commit();
+
+ //add content
+ Tree test = root.getTree("/").addChild("test");
+
+ test.addChild("a").setProperty("propa", "ship_to_canada");
+ test.addChild("b").setProperty("propa", "steamship_to_canada");
+ test.addChild("c").setProperty("propa", "ship_to_can");
+ root.commit();
+ //Thread.sleep(5000);
+
+ String query = "//*[jcr:contains(@propa, '*ship to can*')] ";
+
+ assertEventually(() -> {
+ assertThat(explain(query, XPATH), containsString("elasticsearch:"
+ indexId));
+ assertQuery(query, XPATH, Arrays.asList("/test/a", "/test/b",
"/test/c"));
+ });
+ }
+
+ @Test
+ public void fullTextQueryTestAllowLeadingWildcardsDefault() throws
Exception {
+ IndexDefinitionBuilder builder = createIndex("propa");
+ builder.async("async");
+ builder.indexRule("nt:base").property("propa").analyzed();
+
+ String indexId = UUID.randomUUID().toString();
+ setIndex(indexId, builder);
+ root.commit();
+
+ //add content
+ Tree test = root.getTree("/").addChild("test");
+
+ test.addChild("a").setProperty("propa", "ship_to_canada");
+ test.addChild("b").setProperty("propa", "steamship_to_canada");
+ test.addChild("c").setProperty("propa", "ship_to_can");
+ root.commit();
+ //Thread.sleep(5000);
Review comment:
done
--
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]