RagTool uses chunks results only but in results set the id for full entity is used
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3546744. -->
Reported by: [a.dmitriiev](https://www.drupal.org/user/3235287)
Related to !886
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>RagTool was created from RagAction. The last one had query setting <code>search_api_ai_get_chunks_result</code> but RagTool doesn't have this option anymore, but it assumes that the result items are chunks. In ... the results set is created:</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br> </span><span style="color: #FF8000">// Obtain results.<br> </span><span style="color: #007700">foreach (</span><span style="color: #0000BB">$real_results </span><span style="color: #007700">as </span><span style="color: #0000BB">$match</span><span style="color: #007700">) {<br> </span><span style="color: #0000BB">$id </span><span style="color: #007700">= </span><span style="color: #0000BB">$get_chunked </span><span style="color: #007700">? </span><span style="color: #0000BB">$match</span><span style="color: #007700">[</span><span style="color: #DD0000">'drupal_entity_id'</span><span style="color: #007700">] . </span><span style="color: #DD0000">':' </span><span style="color: #007700">. </span><span style="color: #0000BB">$match</span><span style="color: #007700">[</span><span style="color: #DD0000">'id'</span><span style="color: #007700">] : </span><span style="color: #0000BB">$match</span><span style="color: #007700">[</span><span style="color: #DD0000">'drupal_entity_id'</span><span style="color: #007700">];<br> </span><span style="color: #0000BB">$item </span><span style="color: #007700">= </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">getFieldsHelper</span><span style="color: #007700">()-></span><span style="color: #0000BB">createItem</span><span style="color: #007700">(</span><span style="color: #0000BB">$index</span><span style="color: #007700">, </span><span style="color: #0000BB">$id</span><span style="color: #007700">);<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>From RagTool the <code>$get_chunked</code> is always false, so the entity id is used without the chunk id suffix, this means that the items (chunks) from the same entity will be always overwritten, because they all will have the same <code>$id</code>.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce (required for bugs, but not feature requests)</h4>
<p>Create AI Chatbot that uses AI Agent with RagTool.<br>
Create 2-3 content items that will be search.<br>
When searching with RAG you will always get the same amount of results - as the number of content items you have created, disregarding on how many chunks were actually found.</p>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Add the query option <code>search_api_ai_get_chunks_result</code> in the RAGTool.</p>
issue