This is an automated email from the ASF dual-hosted git repository.
fortino pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/trunk by this push:
new d66b9f7d3e OAK-10672: move internal index version in oak-search (#1327)
d66b9f7d3e is described below
commit d66b9f7d3e047910367d81c244be39f81e0d16df
Author: Fabrizio Fortino <[email protected]>
AuthorDate: Tue Feb 27 15:50:02 2024 +0100
OAK-10672: move internal index version in oak-search (#1327)
* OAK-10672: move internal index version in oak-search
* OAK-10672: (minor) fix typos in comments
* OAK-10672: improve how the mapping version is retried from oak-search
---
.../oak/plugins/index/elastic/index/ElasticIndexHelper.java | 12 +++++++++++-
.../oak/plugins/index/search/FulltextIndexConstants.java | 13 +++++++++++--
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java
index 26950c5e54..2120d41974 100644
---
a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java
+++
b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexHelper.java
@@ -30,6 +30,7 @@ import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.plugins.index.elastic.ElasticIndexDefinition;
import
org.apache.jackrabbit.oak.plugins.index.elastic.ElasticPropertyDefinition;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
+import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants;
import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition;
import org.jetbrains.annotations.NotNull;
@@ -52,8 +53,17 @@ class ElasticIndexHelper {
* Changes not breaking compatibility should increment the minor version
(old queries still work, but they might not
* use the new feature).
* Changes that do not affect queries should increment the patch version
(eg: bug fixes).
+ * <p>
+ * WARN: Since this information might be needed from external tools that
don't have a direct dependency on this module, the
+ * actual version needs to be set in oak-search.
*/
- protected static final String MAPPING_VERSION = "1.1.0";
+ protected static final String MAPPING_VERSION;
+ static {
+ MAPPING_VERSION =
FulltextIndexConstants.INDEX_VERSION_BY_TYPE.get(ElasticIndexDefinition.TYPE_ELASTICSEARCH);
+ if (MAPPING_VERSION == null) {
+ throw new IllegalStateException("Mapping version is not set");
+ }
+ }
// Unset the refresh interval and disable replicas at index creation to
optimize for initial loads
//
https://www.elastic.co/guide/en/elasticsearch/reference/current/tune-for-indexing-speed.html
diff --git
a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/FulltextIndexConstants.java
b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/FulltextIndexConstants.java
index c42fffae1b..595a2b4579 100644
---
a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/FulltextIndexConstants.java
+++
b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/FulltextIndexConstants.java
@@ -17,6 +17,7 @@
package org.apache.jackrabbit.oak.plugins.index.search;
import java.util.Locale;
+import java.util.Map;
/**
* Internal constants used in index definition, and index implementations.
@@ -77,7 +78,7 @@ public interface FulltextIndexConstants {
/**
* Type of the property being indexed defined as part of property
definition
* under the given index definition. Refer to {@link
javax.jcr.PropertyType}
- * contants for the possible values
+ * constants for the possible values
*/
String PROP_TYPE = "type";
@@ -196,7 +197,7 @@ public interface FulltextIndexConstants {
/**
* Limit for maximum number of reaggregates allowed. For example if there
is an aggregate of nt:folder
- * and it also includes nt:folder then aggregation would traverse down
untill this limit is hit
+ * and it also includes nt:folder then aggregation would traverse down
until this limit is hit
*/
String AGG_RECURSIVE_LIMIT = "reaggregateLimit";
@@ -436,4 +437,12 @@ public interface FulltextIndexConstants {
* Boolean property indicating if in-built analyzer should preserve
original term
*/
String INDEX_ORIGINAL_TERM = "indexOriginalTerm";
+
+ /**
+ * Internal version of the index definition for specific index type. Index
version is an information that might be
+ * needed from an outside process that does not have visibility to the
specific index module.
+ */
+ Map<String, String> INDEX_VERSION_BY_TYPE = Map.of(
+ "elasticsearch", "1.1.0"
+ );
}