RagTool uses chunks results only but in results set the id for full entity is used

Created on 15 September 2025, about 2 months ago

Problem/Motivation

RagTool was created from RagAction. The last one had query setting search_api_ai_get_chunks_result but RagTool doesn't have this option anymore, but it assumes that the result items are chunks. In ... the results set is created:

    // Obtain results.
    foreach ($real_results as $match) {
      $id = $get_chunked ? $match['drupal_entity_id'] . ':' . $match['id'] : $match['drupal_entity_id'];
      $item = $this->getFieldsHelper()->createItem($index, $id);

From RagTool the $get_chunked 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 $id.

Steps to reproduce (required for bugs, but not feature requests)

Create AI Chatbot that uses AI Agent with RagTool.
Create 2-3 content items that will be search.
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.

Proposed resolution

Add the query option search_api_ai_get_chunks_result in the RAGTool.

🐛 Bug report
Status

Needs review

Version

1.2

Component

AI Search

Created by

🇩🇪Germany a.dmitriiev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024