AI Search single chunk, takes the lowest ranked chunk

Created on 4 February 2025, 18 days ago

Problem/Motivation

We have the option search_api_ai_get_chunks_result, where if set to false you can choose to get only the highest rated item. This is failing currently.

Looking at: https://git.drupalcode.org/project/ai/-/blob/1.0.x/modules/ai_search/src...

You see that if its not suppose to get all the chunks it iterates and tries to save that it has hit the first result, so it doesn't store the next. However the next else is completely open, causing the addResultItem to run again. Since it only has one ID for all chunks, it just keeps replacing it with a less relevant chunk.

Steps to reproduce

Search for something multichunked in the API Explorer with only one chunk.
Compare to searching for it with all chunks.

Proposed resolution

Just change the else, to elseif ($get_chunked), so it skips this if the first conditional fails.

🐛 Bug report
Status

Active

Version

1.0

Component

AI Search

Created by

🇩🇪Germany marcus_johansson

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024