nfsantos commented on code in PR #1035:
URL: https://github.com/apache/jackrabbit-oak/pull/1035#discussion_r1273270397
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/ElasticIndexDefinition.java:
##########
@@ -269,6 +274,14 @@ public boolean analyzerConfigSplitOnNumerics() {
return getOptionalValue(analyzersTree, SPLIT_ON_NUMERICS, false);
}
+ /**
+ * Returns the mapping version for this index definition.
+ * If the version is not specified, the default value is {@code 1.0.0}.
+ */
+ public String getMappingVersion() {
+ return getOptionalValue(definition, PROP_INDEX_MAPPING_VERSION,
"1.0.0");
+ }
Review Comment:
Shouldn't the default value be a clearly invalid version, like 0.0.0?
Because we will assume that 1.0.0 is a valid version, so it can create
confusion in cases where the index is missing a version, we might assume
wrongly that it has a version.
##########
oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexTest.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.index;
+
+import org.apache.jackrabbit.oak.api.Tree;
+import
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticAbstractQueryTest;
+import
org.apache.jackrabbit.oak.plugins.index.search.util.IndexDefinitionBuilder;
+import org.junit.Test;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+public class ElasticIndexTest extends ElasticAbstractQueryTest {
+
+ @Test
+ public void indexStoresMappingVersion() throws Exception {
+ IndexDefinitionBuilder builder = createIndex("a").noAsync();
+ builder.indexRule("nt:base").property("a").propertyIndex();
+ Tree index = setIndex(UUID.randomUUID().toString(), builder);
+ root.commit();
+
+ assertEventually(() -> assertEquals(ElasticIndexHelper.MAPPING_VERSION,
+ getElasticIndexDefinition(index).getMappingVersion()));
+ }
Review Comment:
It is missing a test that sets the mapping version and checks that it
returns the version that we set.
--
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]