This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch OAK-12010-subset2
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
The following commit(s) were added to refs/heads/OAK-12010-subset2 by this push:
new 6a1db08e91 OAK-12010 Simplified index management (improvements)
6a1db08e91 is described below
commit 6a1db08e91ce105df98541177443b37fdf074939
Author: Thomas Mueller <[email protected]>
AuthorDate: Tue Feb 17 18:48:12 2026 +0100
OAK-12010 Simplified index management (improvements)
---
.../oak/plugins/index/diff/DiffIndex.java | 47 +++--
.../oak/plugins/index/diff/DiffIndexMerger.java | 97 ++++++++---
.../oak/plugins/index/diff/MergeTest.java | 192 ++++++++++-----------
3 files changed, 203 insertions(+), 133 deletions(-)
diff --git
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java
index 41cb53bca5..e976113a76 100644
---
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java
+++
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndex.java
@@ -22,6 +22,7 @@ import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
+import java.util.List;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
@@ -58,21 +59,21 @@ public class DiffIndex {
* @param indexDefinitions the /oak:index node
*/
public static void applyDiffIndexChanges(NodeStore store, NodeBuilder
indexDefinitions) {
- JsonObject diffs = collectDiffs(indexDefinitions);
- if (diffs == null) {
- // nothing todo
- return;
+ JsonObject diffs = collectDiffs(indexDefinitions, MERGER);
+ if (diffs != null) {
+ processDiffs(store, indexDefinitions, diffs, MERGER);
}
- processDiffs(store, indexDefinitions, diffs);
+ storeOrRemoveWarnings(indexDefinitions, MERGER);
}
/**
* Collect the diffs from the diff.index and diff.index.optimizer.
*
* @param indexDefinitions the node builder for /oak:index
+ * @param merger the merger instance to use for collecting warnings
* @return the diffs, or null if none
*/
- public static JsonObject collectDiffs(NodeBuilder indexDefinitions) {
+ public static JsonObject collectDiffs(NodeBuilder indexDefinitions,
DiffIndexMerger merger) {
JsonObject diffs = null;
for (String diffIndex : new String[] {
DiffIndexMerger.DIFF_INDEX,
@@ -113,8 +114,7 @@ public class DiffIndex {
diffs.getChildren().put("/oak:index/" + diffIndex, diffObj);
} catch (Exception e) {
String message = "Error parsing " + diffIndex;
- LOG.warn("{}: {}", message, e.getMessage(), e);
- diffIndexDefinition.setProperty("error", message + ": " +
e.getMessage());
+ merger.logWarn("{}: {}", message, e.getMessage());
}
if (!diffIndexDefinition.hasProperty("info")) {
diffIndexDefinition.setProperty("info", "This diff is
automatically merged with other indexes. See
https://oak-indexing.github.io/oakTools/simplified.html");
@@ -129,13 +129,14 @@ public class DiffIndex {
* @param store the node store
* @param indexDefinitions the node builder for /oak:index
* @param diffs the json object with the combined diffs
+ * @param merger the merger instance to use for collecting warnings
*/
- private static void processDiffs(NodeStore store, NodeBuilder
indexDefinitions, JsonObject diffs) {
+ private static void processDiffs(NodeStore store, NodeBuilder
indexDefinitions, JsonObject diffs, DiffIndexMerger merger) {
LOG.info("Processing diffs");
JsonObject repositoryDefinitions =
RootIndexesListService.getRootIndexDefinitions(indexDefinitions);
LOG.debug("Index list {}", repositoryDefinitions);
try {
- MERGER.merge(diffs, repositoryDefinitions, store);
+ merger.merge(diffs, repositoryDefinitions, store);
for (String indexPath : diffs.getChildren().keySet()) {
if (indexPath.startsWith("/oak:index/" +
DiffIndexMerger.DIFF_INDEX)) {
continue;
@@ -176,6 +177,32 @@ public class DiffIndex {
}
}
+ /**
+ * Store warnings collected during diff index processing in the diff.index
node.
+ * Warnings are stored in separate properties named "warn.01", "warn.02",
etc.
+ * Any existing "warn." properties are removed first.
+ *
+ * @param indexDefinitions the node builder for /oak:index
+ * @param merger the merger instance to retrieve warnings from
+ */
+ public static void storeOrRemoveWarnings(NodeBuilder indexDefinitions,
DiffIndexMerger merger) {
+ if (!indexDefinitions.hasChildNode(DiffIndexMerger.DIFF_INDEX)) {
+ return;
+ }
+ NodeBuilder diffIndexDefinition =
indexDefinitions.child(DiffIndexMerger.DIFF_INDEX);
+ // remove existing warn.* properties
+ for (PropertyState ps :
diffIndexDefinition.getNodeState().getProperties()) {
+ if (ps.getName().startsWith("warn.")) {
+ diffIndexDefinition.removeProperty(ps.getName());
+ }
+ }
+ List<String> warnings = merger.getAndClearWarnings();
+ for (int i = 0; i < warnings.size(); i++) {
+ String name = String.format("warn.%02d", i + 1);
+ diffIndexDefinition.setProperty(name, warnings.get(i));
+ }
+ }
+
private static void sortIndexes(NodeBuilder builder) {
ArrayList<String> list = new ArrayList<>();
for (String child : builder.getChildNodeNames()) {
diff --git
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndexMerger.java
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndexMerger.java
index 2dbb72996d..f2504fe973 100644
---
a/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndexMerger.java
+++
b/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/diff/DiffIndexMerger.java
@@ -23,6 +23,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -81,11 +83,21 @@ public class DiffIndexMerger {
// set of properties that are allowed to be changed if the property
already exists
private final static Set<String> ALLOW_CHANGING_EXISTING_PROPERTY =
Set.of("boost", "weight");
+ // maximum number of warnings to keep
+ private final static int MAX_WARNINGS = 100;
+
+ // maximum total size of warnings (1 MB)
+ private final static int MAX_WARNINGS_SIZE = 1024 * 1024;
+
private String[] unsupportedIncludedPaths;
private boolean deleteCreatesDummyIndex;
private boolean deleteCopiesOutOfTheBoxIndex;
private boolean logAtInfoLevel;
+ // thread-safe queue to store warnings (oldest first)
+ private final LinkedList<String> warnings = new LinkedList<>();
+ private int warningsSize = 0;
+
public DiffIndexMerger() {
this(UNSUPPORTED_INCLUDED_PATHS, DELETE_CREATES_DUMMY,
DELETE_COPIES_OOTB, LOG_AT_INFO_LEVEL);
}
@@ -173,12 +185,7 @@ public class DiffIndexMerger {
String key = e.getKey();
JsonObject value = e.getValue();
if (key.startsWith("/oak:index/")) {
-
-// document this:
-// enumerate error messages
-// do not log but write to index def
-
- LOG.warn("The key should contain just the index name, without
the '/oak:index' prefix for key {}", key);
+ logWarn("The key should contain just the index name, without
the '/oak:index' prefix, for key: {}", key);
key = key.substring("/oak:index/".length());
}
log("Processing {}", key);
@@ -203,7 +210,7 @@ public class DiffIndexMerger {
* @param target the target map of diff.index definitions
* @return the error message trying to parse the JSON file, or null
*/
- public static String tryExtractDiffIndex(JsonObject indexDefs, String
name, HashMap<String, JsonObject> target) {
+ public String tryExtractDiffIndex(JsonObject indexDefs, String name,
HashMap<String, JsonObject> target) {
JsonObject diffIndex = indexDefs.getChildren().get(name);
if (diffIndex == null) {
return null;
@@ -216,15 +223,15 @@ public class DiffIndexMerger {
JsonObject jcrContent = file.getChildren().get("jcr:content");
if (jcrContent == null) {
String message = "jcr:content child node is missing in
diff.json";
- LOG.warn(message);
+ logWarn(message);
return message;
}
String jcrData = JsonNodeUpdater.oakStringValue(jcrContent,
"jcr:data");
try {
diff = JsonObject.fromJson(jcrData, true);
} catch (Exception e) {
- LOG.warn("Illegal Json, ignoring: {}", jcrData, e);
String message = "Illegal Json, ignoring: " + e.getMessage();
+ logWarn("Illegal Json, ignoring: {}", jcrData, e);
return message;
}
} else {
@@ -359,13 +366,13 @@ public class DiffIndexMerger {
JsonObject latestProductIndex =
combined.getChildren().get(latestProductKey);
String[] includedPaths;
if (latestProductIndex == null) {
- if (indexDiff.getProperties().isEmpty() &&
indexDiff.getChildren().isEmpty()) {
+ if (indexDiff == null || indexDiff.getProperties().isEmpty() &&
indexDiff.getChildren().isEmpty()) {
// there is no customization (any more), which means a dummy
index may be needed
log("No customization for {}", indexName);
} else {
includedPaths = JsonNodeUpdater.oakStringArrayValue(indexDiff,
"includedPaths");
if (includesUnsupportedPaths(includedPaths)) {
- LOG.warn("New custom index {} is not supported because it
contains an unsupported path ({})",
+ logWarn("New custom index {} is not supported because it
contains an unsupported path ({})",
indexName,
Arrays.toString(unsupportedIncludedPaths));
return false;
}
@@ -373,7 +380,7 @@ public class DiffIndexMerger {
} else {
includedPaths =
JsonNodeUpdater.oakStringArrayValue(latestProductIndex, "includedPaths");
if (includesUnsupportedPaths(includedPaths)) {
- LOG.warn("Customizing index {} is not supported because it
contains an unsupported path ({})",
+ logWarn("Customizing index {} is not supported because it
contains an unsupported path ({})",
latestProductKey,
Arrays.toString(unsupportedIncludedPaths));
return false;
}
@@ -389,7 +396,7 @@ public class DiffIndexMerger {
}
merged = latestProductIndex;
} else {
- merged = processMerge(latestProductIndex, indexDiff);
+ merged = processMerge(indexName, latestProductIndex, indexDiff);
}
// compare to the latest version of the this index
@@ -415,8 +422,8 @@ public class DiffIndexMerger {
// (even if checksums do not match: checksums might be missing
or manipulated)
log("Latest index matches");
if (latestMergeChecksum != null &&
!latestMergeChecksum.equals(mergeChecksum)) {
- LOG.warn("Indexes do match, but checksums do not. Possibly
checksum was changed: {} vs {}", latestMergeChecksum, mergeChecksum);
- LOG.warn("latest: {}\nmerged: {}", latestDef, mergedDef);
+ logWarn("Indexes do match, but checksums do not. Possibly
checksum was changed: {} vs {}", latestMergeChecksum, mergeChecksum);
+ logWarn("Index: {}, latest: {}\nmerged: {}", indexName,
latestDef, mergedDef);
}
return false;
}
@@ -424,8 +431,8 @@ public class DiffIndexMerger {
// checksum matches, but data does not match
// could be eg. due to numbers formatting issues (-0.0 vs 0.0,
0.001 vs 1e-3)
// but unexpected because we do not normally have such cases
- LOG.warn("Indexes do not match, but checksums match. Possible
normalization issue.");
- LOG.warn("Index: {}, latest: {}\nmerged: {}", indexName,
latestDef, mergedDef);
+ logWarn("Indexes do not match, but checksums match. Possible
normalization issue.");
+ logWarn("Index: {}, latest: {}\nmerged: {}", indexName,
latestDef, mergedDef);
// if checksums match, we consider it a match
return false;
}
@@ -641,11 +648,13 @@ public class DiffIndexMerger {
* Merge a product index with a diff. If the product index is null, then
the
* diff needs to contain a complete custom index definition.
*
+ * @param indexName the index name (for logging)
* @param productIndex the product index definition, or null if none
* @param diff the diff (from the diff.index definition)
+ *
* @return the index definition of the merged index
*/
- public JsonObject processMerge(JsonObject productIndex, JsonObject diff) {
+ public JsonObject processMerge(String indexName, JsonObject productIndex,
JsonObject diff) {
JsonObject result;
boolean isNew;
if (productIndex == null) {
@@ -656,7 +665,7 @@ public class DiffIndexMerger {
result = JsonObject.fromJson(productIndex.toString(), true);
isNew = false;
}
- mergeInto("", diff, result, isNew);
+ mergeInto(indexName, "", diff, result, isNew);
addPrimaryType("", result);
return result;
}
@@ -692,12 +701,14 @@ public class DiffIndexMerger {
/**
* Merge a JSON diff into a target index definition.
*
- * @param path the path
+ * @param indexName the index name (for logging)
+ * @param path the path (relative to the index)
* @param diff the diff (what to merge)
* @param target where to merge into
* @param isNew whether the target node is newly created (didn't exist
before)
*/
- private void mergeInto(String path, JsonObject diff, JsonObject target,
boolean isNew) {
+ private void mergeInto(String indexName, String path, JsonObject diff,
JsonObject target, boolean isNew) {
+ String pathForLogging = path.isEmpty() ? "the root" : "replative path
" + path;
for (String p : diff.getProperties().keySet()) {
if (path.isEmpty()) {
if ("jcr:primaryType".equals(p)) {
@@ -708,12 +719,12 @@ public class DiffIndexMerger {
// for existing nodes, we do a few more checks before the merge
if (path.isEmpty() &&
REJECTED_TOP_LEVEL_PROPS_FOR_EXISTING_INDEX.contains(p)) {
// at the top level, some properties (eg. selectionPolicy)
are not allowed to be added to an existing index
- LOG.warn("Ignoring new top-level property {} at {} for
existing index", p, path);
+ logWarn("{}: Ignoring new top-level property {} at {} for
existing index", indexName, p, pathForLogging);
continue;
}
if (REJECTED_PROPS_FOR_EXISTING_PROPERTY.contains(p)) {
// the some properties are not allowed to be added if the
node already exists
- LOG.warn("Ignoring new property {} at {} for existing
child", p, path);
+ logWarn("{}: Ignoring new property \"{}\" at {} for
existing child", indexName, p, pathForLogging);
continue;
}
}
@@ -721,8 +732,7 @@ public class DiffIndexMerger {
// we do not currently allow to overwrite most existing
properties,
// except for:
if (ALLOW_CHANGING_EXISTING_PROPERTY.contains(p)) {
- // allow overwriting the boost value
- LOG.info("Overwrite property {} value at {}", p, path);
+ // allow overwriting the (eg.) boost value
target.getProperties().put(p, diff.getProperties().get(p));
} else if (path.isEmpty() && (p.equals("includedPaths") ||
p.equals("queryPaths") || p.equals("tags"))) {
// merge includedPaths, queryPaths, and tags
@@ -741,7 +751,7 @@ public class DiffIndexMerger {
target.getProperties().put(p,
buff.endArray().toString());
}
} else {
- LOG.warn("Ignoring existing property {} at {}", p, path);
+ logWarn("{}: Ignoring existing property \"{}\" at {}",
indexName, p, pathForLogging);
}
} else {
target.getProperties().put(p, diff.getProperties().get(p));
@@ -779,7 +789,7 @@ public class DiffIndexMerger {
} else {
childIsNew = false;
}
- mergeInto(path + "/" + targetChildName, diff.getChildren().get(c),
target.getChildren().get(targetChildName), childIsNew);
+ mergeInto(indexName, path + "/" + targetChildName,
diff.getChildren().get(c), target.getChildren().get(targetChildName),
childIsNew);
}
if (target.getProperties().isEmpty() &&
target.getChildren().isEmpty()) {
if (deleteCreatesDummyIndex) {
@@ -888,6 +898,39 @@ public class DiffIndexMerger {
}
}
+ /**
+ * Log a warning message and store it in a size-limited queue.
+ * The queue keeps the oldest entries and is limited to 100 entries or 1
MB total size.
+ *
+ * @param format the log message format
+ * @param arguments the log message arguments
+ */
+ public void logWarn(String format, Object... arguments) {
+ String message =
org.slf4j.helpers.MessageFormatter.arrayFormat(format, arguments).getMessage();
+ LOG.warn(message);
+ synchronized (warnings) {
+ int messageSize = message.getBytes(StandardCharsets.UTF_8).length;
+ if (warnings.size() < MAX_WARNINGS && warningsSize + messageSize
<= MAX_WARNINGS_SIZE) {
+ warnings.add(message);
+ warningsSize += messageSize;
+ }
+ }
+ }
+
+ /**
+ * Get and clear all collected warnings.
+ *
+ * @return a list of warning messages (oldest first)
+ */
+ public List<String> getAndClearWarnings() {
+ synchronized (warnings) {
+ List<String> result = new ArrayList<>(warnings);
+ warnings.clear();
+ warningsSize = 0;
+ return result;
+ }
+ }
+
public DiffIndexMerger setUnsupportedIncludedPaths(String[]
unsupportedIncludedPaths) {
this.unsupportedIncludedPaths = unsupportedIncludedPaths;
return this;
diff --git
a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diff/MergeTest.java
b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diff/MergeTest.java
index 76cafdc642..217fde0ca5 100644
---
a/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diff/MergeTest.java
+++
b/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/diff/MergeTest.java
@@ -90,7 +90,7 @@ public class MergeTest {
+ " }", true);
HashMap<String, JsonObject> target = new HashMap<>();
- DiffIndexMerger.tryExtractDiffIndex(repositoryDefinitions,
"/oak:index/diff.index", target);
+ new DiffIndexMerger().tryExtractDiffIndex(repositoryDefinitions,
"/oak:index/diff.index", target);
assertEquals("{damAssetLucene={\n"
+ " \"indexRules\": {\n"
+ " \"dam:Asset\": {\n"
@@ -110,25 +110,25 @@ public class MergeTest {
// A property might be indexed twice, by adding two children to the
"properties" node
// that both have the same "name" value.
// Alternatively, they could have the same "function" value.
- String merged = new
DiffIndexMerger().processMerge(JsonObject.fromJson("{\n"
- + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
- + " \"type\": \"lucene\",\n"
- + " \"indexRules\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"acme:Test\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"properties\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"abc\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"name\": \"test\",\n"
- + " \"boost\": 1.0\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }"
- + "", true), JsonObject.fromJson("{\n"
+ String merged = new DiffIndexMerger().processMerge(null,
JsonObject.fromJson("{\n"
+ + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
+ + " \"type\": \"lucene\",\n"
+ + " \"indexRules\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"acme:Test\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"properties\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"abc\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"name\": \"test\",\n"
+ + " \"boost\": 1.0\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }"
+ + "", true), JsonObject.fromJson("{\n"
+ " \"indexRules\": {\n"
+ " \"acme:Test\": {\n"
+ " \"properties\": {\n"
@@ -166,24 +166,24 @@ public class MergeTest {
// some additions are not allowed, as they could result in the index
// to be not usable for existing queries
// (eg. the selectionPolicy may not be set if the index already exists)
- String merged = new
DiffIndexMerger().processMerge(JsonObject.fromJson("{\n"
- + " \"jcr:primaryType\": \"nam:oak:IndexDefinition\",\n"
- + " \"type\": \"lucene\",\n"
- + " \"async\": [\"async\", \"nrt\"],\n"
- + " \"indexRules\": {\n"
- + " \"dam:Asset\": {\n"
- + " \"properties\": {\n"
- + " \"named\": {\n"
- + " \"name\": \"x\"\n"
- + " },\n"
- + " \"functionBased\": {\n"
- + " \"function\": \"upper(x)\"\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + "", true), JsonObject.fromJson("{ \n"
+ String merged = new DiffIndexMerger().processMerge(null,
JsonObject.fromJson("{\n"
+ + " \"jcr:primaryType\":
\"nam:oak:IndexDefinition\",\n"
+ + " \"type\": \"lucene\",\n"
+ + " \"async\": [\"async\", \"nrt\"],\n"
+ + " \"indexRules\": {\n"
+ + " \"dam:Asset\": {\n"
+ + " \"properties\": {\n"
+ + " \"named\": {\n"
+ + " \"name\": \"x\"\n"
+ + " },\n"
+ + " \"functionBased\": {\n"
+ + " \"function\":
\"upper(x)\"\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "", true), JsonObject.fromJson("{ \n"
+ " \"tags\": [\"newTag\"],\n"
+ " \"selectionPolicy\": \"tag\",\n"
+ " \"indexRules\": {\n"
@@ -230,24 +230,24 @@ public class MergeTest {
@Test
public void customizeIncludedPathsQueryPathsAndTags() {
- String merged = new
DiffIndexMerger().processMerge(JsonObject.fromJson("{\n"
- + " \"jcr:primaryType\": \"nam:oak:IndexDefinition\",\n"
- + " \"type\": \"lucene\",\n"
- + " \"async\": [\"async\", \"nrt\"],\n"
- + " \"tags\": [\"abc\", \"def\"],\n"
- + " \"includedPaths\": \"/content/dam\",\n"
- + " \"indexRules\": {\n"
- + " \"dam:Asset\": {\n"
- + " \"properties\": {\n"
- + " \"x\": {\n"
- + " \"name\": \"x\",\n"
- + " \"propertyIndex\": true\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + "", true), JsonObject.fromJson("{ \n"
+ String merged = new DiffIndexMerger().processMerge(null,
JsonObject.fromJson("{\n"
+ + " \"jcr:primaryType\":
\"nam:oak:IndexDefinition\",\n"
+ + " \"type\": \"lucene\",\n"
+ + " \"async\": [\"async\", \"nrt\"],\n"
+ + " \"tags\": [\"abc\", \"def\"],\n"
+ + " \"includedPaths\": \"/content/dam\",\n"
+ + " \"indexRules\": {\n"
+ + " \"dam:Asset\": {\n"
+ + " \"properties\": {\n"
+ + " \"x\": {\n"
+ + " \"name\": \"x\",\n"
+ + " \"propertyIndex\": true\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + "", true), JsonObject.fromJson("{ \n"
+ " \"includedPaths\": [\"/content/dam\",
\"/content/additional\" ],\n"
+ " \"tags\": [\"def\", \"ghi\" ]\n"
+ " }", true)).toString();
@@ -278,25 +278,25 @@ public class MergeTest {
public void renamedFunction() {
// A function might be indexed twice, by adding two children to the
"properties" node
// that both have the same "function" value.
- String merged = new
DiffIndexMerger().processMerge(JsonObject.fromJson("{\n"
- + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
- + " \"type\": \"lucene\",\n"
- + " \"indexRules\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"acme:Test\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"properties\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"abc\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"function\": \"upper(test)\",\n"
- + " \"boost\": 1.0\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }"
- + "", true), JsonObject.fromJson("{\n"
+ String merged = new DiffIndexMerger().processMerge(null,
JsonObject.fromJson("{\n"
+ + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
+ + " \"type\": \"lucene\",\n"
+ + " \"indexRules\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"acme:Test\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"properties\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"abc\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"function\": \"upper(test)\",\n"
+ + " \"boost\": 1.0\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }"
+ + "", true), JsonObject.fromJson("{\n"
+ " \"indexRules\": {\n"
+ " \"acme:Test\": {\n"
+ " \"properties\": {\n"
@@ -332,8 +332,8 @@ public class MergeTest {
public void createDummy() {
// when enabling "deleteCreatesDummyIndex", then a dummy index is
created
// (that indexes /dummy, which doesn't exist)
- String merged = new DiffIndexMerger(new String[0], true, true,
false).processMerge(JsonObject.fromJson("{}"
- + "", true), JsonObject.fromJson("{}", true)).toString();
+ String merged = new DiffIndexMerger(new String[0], true, true,
false).processMerge(null, JsonObject.fromJson("{}"
+ + "", true), JsonObject.fromJson("{}",
true)).toString();
assertEquals("{\n"
+ " \"async\": \"async\",\n"
+ " \"includedPaths\": \"/dummy\",\n"
@@ -359,25 +359,25 @@ public class MergeTest {
// - "analyzed" must not be overwritten
// - "ordered" is added
// - "boost" is overwritten
- String merged = new
DiffIndexMerger().processMerge(JsonObject.fromJson("{\n"
- + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
- + " \"type\": \"lucene\",\n"
- + " \"indexRules\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"acme:Test\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"properties\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"abc\": {\n"
- + " \"jcr:primaryType\": \"nam:nt:unstructured\",\n"
- + " \"analyzed\": true,\n"
- + " \"boost\": 1.0\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }\n"
- + " }"
- + "", true), JsonObject.fromJson("{\n"
+ String merged = new DiffIndexMerger().processMerge(null,
JsonObject.fromJson("{\n"
+ + " \"jcr:primaryType\":
\"nam:oak:QueryIndexDefinition\",\n"
+ + " \"type\": \"lucene\",\n"
+ + " \"indexRules\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"acme:Test\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"properties\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"abc\": {\n"
+ + " \"jcr:primaryType\":
\"nam:nt:unstructured\",\n"
+ + " \"analyzed\": true,\n"
+ + " \"boost\": 1.0\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }\n"
+ + " }"
+ + "", true), JsonObject.fromJson("{\n"
+ " \"indexRules\": {\n"
+ " \"acme:Test\": {\n"
+ " \"properties\": {\n"