Skip to content

Conversation

@kderusso
Copy link
Member

@kderusso kderusso commented Nov 14, 2025

Updates CHUNK to support chunking_settings as an optional argument. Removes num_chunks, in favor of MV_SLICE.

Usage:

CHUNK(content, {"strategy": "sentence", "max_chunk_size": 50, "sentence_overlap": 0 })

@github-actions
Copy link
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far LGTM - I think the options validation is correct (missing some tests) but the direction is good!

As a drive-by comment - I find a bit confusing having to add nested options when we have a single other param (num_chunks):

CHUNK(content, {"num_chunks": 3, "chunking_settings": { "strategy": "sentence", "max_chunk_size": 50, "sentence_overlap": 0 } })
}

Wouldn't it be better to avoid having to specify chunking_settings as an additional option, and just flatten the chunking settings into the overall options?

CHUNK(content, {"num_chunks": 3, "strategy": "sentence", "max_chunk_size": 50, "sentence_overlap": 0 })
}

We can do the same chunking building if we remove the num_chunks from the options map and then try to build from there 🤷

@kderusso
Copy link
Member Author

Wouldn't it be better to avoid having to specify chunking_settings as an additional option, and just flatten the chunking settings into the overall options?

@carlosdelest So I get that, but here's the rub - various chunking settings strategies have different options. For example, sentence based chunking requires sentence_overlap but word based chunking requires overlap. And none would have no overlap. So if we were to flatten out these options, we'd have to take every possible permutation into account and commit to updating it going forward. The nested options felt better to me, because we can defer to the chunking settings builder to validate the options. This is the strategy we went with for semantic_text fields and it works well, because when new chunking settings are added they seamlessly work.

I realize the nested syntax is confusing but I'm just not sure if there's a better way to do that.

We can optimize for semantic_text fields and have reasonable default chunking strategies, and we've discussed whether we want to use an inference ID to pull chunking settings (this has some complications because of jarhell issues with inference and esql). But this felt like the first step, because it offers that flexibility. WDYT?

@carlosdelest
Copy link
Member

various chunking settings strategies have different options. For example, sentence based chunking requires sentence_overlap but word based chunking requires overlap. And none would have no overlap. So if we were to flatten out these options, we'd have to take every possible permutation into account and commit to updating it going forward.

@kderusso I'm not sure that I understand. Can't we take this option map:

{"num_chunks": 3, "strategy": "sentence", "max_chunk_size": 50, "sentence_overlap": 0}

and just send it to the ChunkingSettingsBuilder, removing the num_chunks from it?

@kderusso
Copy link
Member Author

@kderusso I'm not sure that I understand. Can't we take this option map:

{"num_chunks": 3, "strategy": "sentence", "max_chunk_size": 50, "sentence_overlap": 0}

and just send it to the ChunkingSettingsBuilder, removing the num_chunks from it?

I suppose that's an option, to send in all other options as a big bag'o'options, but I'm not thrilled with that for future API extensibility - if we ever add additional options like super_excellent_widget then it really complicates everything? Maybe I'm overthinking it, it's a good discussion - would like to hear from @ioanatia on this too.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 19, 2025

🔍 Preview links for changed docs


public static final int DEFAULT_NUM_CHUNKS = Integer.MAX_VALUE;
public static final int DEFAULT_CHUNK_SIZE = 300;
static final int DEFAULT_CHUNK_SIZE = 300;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this to 5500, which per #132169 should be Jina's rerank window size?

@kderusso kderusso marked this pull request as ready for review November 19, 2025 21:23
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Nov 19, 2025
@kderusso kderusso added >enhancement :Search Relevance/ES|QL Search functionality in ES|QL and removed needs:triage Requires assignment of a team area label labels Nov 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Nov 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @kderusso, I've created a changelog YAML for you.

@kderusso kderusso requested a review from a team November 19, 2025 21:25
Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Let's address Ioana's concerns - the rest LGTM

@kderusso kderusso requested a review from ioanatia November 21, 2025 21:28
result.appendNull();
continue position;
}
switch (numChunksBlock.getValueCount(p)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ I really like how much you simplified things here ❤️

@kderusso kderusso merged commit 3aba4cd into elastic:main Nov 24, 2025
34 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Nov 24, 2025
…-json

* upstream/main: (247 commits)
  Mute org.elasticsearch.xpack.inference.integration.SemanticTextIndexOptionsIT testValidateIndexOptionsWithBasicLicense elastic#138513
  Mute org.elasticsearch.xpack.esql.heap_attack.HeapAttackLookupJoinIT testLookupExplosionBigString elastic#138510
  This shouldn't be zero (elastic#138501)
  sum of empty histogram is now null (elastic#138378)
  Test ES|QL bfloat16 support (elastic#138499)
  Fix exception handling in S3 `compareAndExchangeRegister` (elastic#138488)
  Mute org.elasticsearch.xpack.exponentialhistogram.ExponentialHistogramFieldMapperTests testFormattedDocValues elastic#138504
  Mute org.elasticsearch.ingest.geoip.IngestGeoIpClientYamlTestSuiteIT test {yaml=ingest_geoip/60_ip_location_databases/Test adding, getting, and removing ip location databases} elastic#138502
  ESQL: Refactor HeapAttackIT (elastic#138432)
  [Inference API] Add ElasticInferenceServiceDenseTextEmbeddingsServiceSettings to InferenceNamedWriteablesProvider (elastic#138484)
  Store split indices (elastic#138396)
  ES|QL Update CHUNK to support chunking_settings as optional argument (elastic#138123)
  Extract common blob-update logic in `S3HttpHandler` (elastic#138490)
  Cleanup esql request building api (elastic#138398)
  Round sum and avg in exponential_histogram CSV tests (elastic#138472)
  ESQL: load exponential_histogram total count as double instead of long (elastic#138417)
  [SIMD] Use fixed width native types for better Java interoperability (elastic#138429)
  Do not use Min or Max as Top's surrogate when there is an outputField (elastic#138380)
  ES|QL: Fix generative tests (elastic#138478)
  Mute org.elasticsearch.xpack.inference.integration.AuthorizationTaskExecutorIT testCreatesEisChatCompletion_DoesNotRemoveEndpointWhenNoLongerAuthorized elastic#138480
  ...
afoucret pushed a commit to afoucret/elasticsearch that referenced this pull request Nov 26, 2025
…lastic#138123)

* Stash claude changes

* Update

* test

* fix

* iter

* iter

* tests

* [CI] Auto commit changes from spotless

* Remove num chunks, change options to chunking settings map

* [CI] Auto commit changes from spotless

* Verifier tests

* Update docs/changelog/138123.yaml

* [CI] Auto commit changes from spotless

* PR Feedback

* [CI] Auto commit changes from spotless

* Checkpoint - mid refactoring to support chunking setting explicit options, tests don't work

* [CI] Auto commit changes from spotless

* fix separators issue

* Docs

* cleanup

* Cleanup

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
ncordon pushed a commit to ncordon/elasticsearch that referenced this pull request Nov 26, 2025
…lastic#138123)

* Stash claude changes

* Update

* test

* fix

* iter

* iter

* tests

* [CI] Auto commit changes from spotless

* Remove num chunks, change options to chunking settings map

* [CI] Auto commit changes from spotless

* Verifier tests

* Update docs/changelog/138123.yaml

* [CI] Auto commit changes from spotless

* PR Feedback

* [CI] Auto commit changes from spotless

* Checkpoint - mid refactoring to support chunking setting explicit options, tests don't work

* [CI] Auto commit changes from spotless

* fix separators issue

* Docs

* cleanup

* Cleanup

* [CI] Auto commit changes from spotless

---------

Co-authored-by: elasticsearchmachine <infra-root+elasticsearchmachine@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Relevance/ES|QL Search functionality in ES|QL Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants