You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2025/02/26 13:47:43 UTC
(jackrabbit-oak) branch OAK-11530 created (now 44a1faaab1)
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a change to branch OAK-11530
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 44a1faaab1 OAK-11530 Elasticsearch: 'field name cannot be an empty string' if fields start with a dot
This branch includes the following new commits:
new 44a1faaab1 OAK-11530 Elasticsearch: 'field name cannot be an empty string' if fields start with a dot
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11530 Elasticsearch: 'field name cannot be an empty string' if fields start with a dot
Posted by th...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch OAK-11530
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 44a1faaab183e76dec223fad7a08802646372daa
Author: Thomas Mueller <th...@apache.org>
AuthorDate: Wed Feb 26 14:47:20 2025 +0100
OAK-11530 Elasticsearch: 'field name cannot be an empty string' if fields start with a dot
---
.../index/elastic/index/ElasticIndexWriter.java | 24 ++++++++++++++++++++++
.../elastic/index/ElasticIndexWriterTest.java | 14 +++++++++++++
2 files changed, 38 insertions(+)
diff --git a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java
index d7465632a7..d6fe68ff87 100644
--- a/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java
+++ b/oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriter.java
@@ -204,11 +204,35 @@ class ElasticIndexWriter implements FulltextIndexWriter<ElasticDocument> {
if (ese.status() == 400 && ese.getMessage().contains("resource_already_exists_exception")) {
LOG.warn("Index {} already exists. Ignoring error", indexName);
} else {
+ LOG.warn("Failed to create index {}", indexName, ese);
+ StringBuilder sb = new StringBuilder();
+ int old = JsonpUtils.maxToStringLength();
+ try {
+ JsonpUtils.maxToStringLength(16_000_000);
+ JsonpUtils.toString(request, sb);
+ String[] array = splitLargeString(sb.toString(), 1024);
+ for (int i = 0; i < array.length; i++) {
+ LOG.warn("request chunk[{}] = {}", i, array[i]);
+ }
+ } finally {
+ JsonpUtils.maxToStringLength(old);
+ }
throw ese;
}
}
}
+ public static String[] splitLargeString(String largeString, int chunkSize) {
+ int totalChunks = (largeString.length() + chunkSize - 1) / chunkSize;
+ String[] array = new String[totalChunks];
+ for (int i = 0; i < totalChunks; i++) {
+ int start = i * chunkSize;
+ int end = Math.min(start + chunkSize, largeString.length());
+ array[i] = largeString.substring(start, end);
+ }
+ return array;
+ }
+
private void enableIndex() throws IOException {
ElasticsearchIndicesClient client = elasticConnection.getClient().indices();
// check if index already exists
diff --git a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterTest.java b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterTest.java
index ccd7dc2e05..2b58d80cfa 100644
--- a/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterTest.java
+++ b/oak-search-elastic/src/test/java/org/apache/jackrabbit/oak/plugins/index/elastic/index/ElasticIndexWriterTest.java
@@ -27,6 +27,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import java.io.IOException;
+import java.util.Arrays;
import static org.apache.jackrabbit.oak.plugins.index.elastic.ElasticTestUtils.randomString;
import static org.hamcrest.CoreMatchers.not;
@@ -130,4 +131,17 @@ public class ElasticIndexWriterTest {
verify(bulkProcessorHandlerMock).update(anyString(), any(ElasticDocument.class));
}
+ @Test
+ public void splitLargeString() {
+ assertEquals("[a]",
+ Arrays.toString(ElasticIndexWriter.splitLargeString(
+ "a", 1024)));
+ assertEquals("[h, e, l, l, o, , w, o, r, l, d]",
+ Arrays.toString(ElasticIndexWriter.splitLargeString(
+ "hello world", 1)));
+ assertEquals("[he, ll, o , wo, rl, d]",
+ Arrays.toString(ElasticIndexWriter.splitLargeString(
+ "hello world", 2)));
+ }
+
}