fabriziofortino commented on code in PR #2099:
URL: https://github.com/apache/jackrabbit-oak/pull/2099#discussion_r1963118587


##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticRegexPropertyIndexTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.index.elastic;
+
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.util.List;
+
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants;
+import 
org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder;
+import 
org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder.PropertyRule;
+import org.junit.Test;
+
+public class ElasticRegexPropertyIndexTest extends ElasticAbstractQueryTest {
+
+    @Test
+    public void regexProperty() throws Exception {
+        IndexDefinitionBuilder builder = createIndex("allProperties");
+        PropertyRule prop = 
builder.indexRule("nt:base").property("allProperties");
+        
prop.getBuilderTree().setProperty(FulltextIndexConstants.PROP_IS_REGEX, true);
+        prop.getBuilderTree().setProperty(FulltextIndexConstants.PROP_NAME, 
"^[^\\/]*$");
+        prop.nodeScopeIndex();
+        
prop.getBuilderTree().setProperty(ElasticPropertyDefinition.PROP_IS_FLATTENED, 
true);
+        
+        setIndex("test1", builder);
+        root.commit();
+
+        Tree test = root.getTree("/").addChild("test");
+        test.addChild("a").setProperty("propa", "foo");
+        test.addChild("b").setProperty("propa", "foo");
+        test.addChild("c").setProperty("propa", "foo2");
+        test.addChild("d").setProperty("propc", "foo");
+        test.addChild("e").setProperty("propd", "foo");
+        root.commit();

Review Comment:
   minor: I have slightly modified the test to simulate a scenario with high 
cardinality and it works well. It does not break and performance are okay. Feel 
free to include it if you think is useful.
   ```suggestion
          // create 10k nodes with different property names to have high 
cardinality
           for (int i = 0; i < 10000; i++) {
               test.addChild("node" + i).setProperty("prop" + i, "foo");
           }
           root.commit();
   ```



-- 
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