Long node titles can trigger exception 'The minimum overlap cannot be equal to or exceed the maximum chunk size.' when indexing content
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3520606. -->
Reported by: [coffeymachine](https://www.drupal.org/user/794774)
Related to !569 !929
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Sometimes, nodes with long titles (more than 160 characters or so) crash the indexing process with the error: <strong>The minimum overlap cannot be equal to or exceed the maximum chunk size.</strong><br>
This appears to be due to the EmbeddingBase chunking both the contextual content and the main fields. When the contextual content is chunked, the chunk size is calculated using the title length. When the title is long, it can result in a calculated chunk size that is smaller than the configured minimum overlap.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ul>
<li>Set up a search index with embeddings as described in <a href="https://www.youtube.com/watch?v=ZpLxpp9BJ1c">(YouTube) Drupal AI Module Alpha 6 Update - AI Search (pt 3/3)</a>
</li>
<li>Configure the index fields with <strong>Rendered HTML output</strong> for the Main content and <strong>Title</strong> for the Contextual content</li>
<li>Set the search server config:
<ul>
<li><strong>Maximum chunk size</strong>: 500</li>
<li><strong>Minimum chunk overlap</strong>: 100</li>
<li><strong>Contextual content maximum percentage</strong>: 30%</li>
</ul>
</li>
<li>Create a node with a long title (160+ characters)</li>
<li>Run the index process</li>
</ul>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Reduce the minimum overlap for contextual chunks using the <strong>Contextual content maximum percentage</strong>. This has the added benefit of significantly reducing the number of chunks generated per node.</p>
issue