diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/chunking/SentenceBoundaryChunker.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/chunking/SentenceBoundaryChunker.java index 0924fc71f8665..f36dfb694a752 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/chunking/SentenceBoundaryChunker.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/chunking/SentenceBoundaryChunker.java @@ -157,7 +157,7 @@ public List chunk(String input, int maxNumberWordsPerChunk, boolean incl if (chunks.isEmpty()) { // The input did not chunk, return the entire input - chunks.add(new ChunkOffset(0, input.length())); + chunks.add(input); } return chunks; diff --git a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/chunking/WordBoundaryChunkerTests.java b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/chunking/WordBoundaryChunkerTests.java index 982e3643741d6..93f951bbfa983 100644 --- a/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/chunking/WordBoundaryChunkerTests.java +++ b/x-pack/plugin/inference/src/test/java/org/elasticsearch/xpack/inference/chunking/WordBoundaryChunkerTests.java @@ -227,6 +227,10 @@ public void testWhitespace() { assertThat(chunks, contains(" ")); } + private List textChunks(WordBoundaryChunker chunker, String input, int chunkSize, int overlap) { + return chunker.chunk(input, chunkSize, overlap); + } + public void testBlankString() { var chunks = textChunks(new WordBoundaryChunker(), " ", 100, 10); assertThat(chunks, hasSize(1));