AI Search: Undefined array key "id"

Created on 6 February 2025, 16 days ago

Hey there, was doing some work around the module, spotted this weird behavior.
We are using:

Problem/Motivation

What I get:

Warning: Undefined array key "id" in Drupal\ai_search\Plugin\search_api\backend\SearchApiAiSearchBackend->search() (line 429 of modules/contrib/ai/modules/ai_search/src/Plugin/search_api/backend/SearchApiAiSearchBackend.php).

Why:

    foreach ($real_results as $match) {
      $id = $get_chunked ? $match['drupal_entity_id'] . ':' . $match['id'] : $match['drupal_entity_id'];

Debugging this, pinecone's metadata (and metadata is what is in $match) doesn't have the 'id' key. Idk if it should have, or if ai_search should handle the case for missing $match['id'].

Steps to reproduce

Use Drupal AI (this module), Pinecone as VDB (ai_vdb_provider_pinecone) and https://www.drupal.org/project/ai_search_block
Configure the search and result block - place them somewhere, make sure it's "Streaming" and uses RAG.

When you'd use streaming flavor - it works well, but then once you refresh you get a lot of warnings on that id.

Proposed resolution

Either ai_search or ai_vdb_provider_pinecone should fix this - so I need someone's opinion on this (I don't have alternative vectordb to test with).

🐛 Bug report
Status

Active

Version

1.0

Component

AI Search

Created by

🇪🇸Spain Nikro Benalmadena, Malaga

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

Comments & Activities

  • Issue created by @Nikro
  • 🇪🇸Spain Nikro Benalmadena, Malaga

    After a bit of research - probably it's a part of the other module (as a 'normalization' step).
    Closing this for now in favor of https://www.drupal.org/project/ai_vdb_provider_pinecone/issues/3504826 🐛 Results should include 'id' Active - will submit a small patch there.

Production build 0.71.5 2024