SQL Error: String values not quoted in INSERT for 'Filterable attributes' (select string fields)

Created on 20 August 2025, 11 days ago

Problem Description:

When attempting to index a Search API index using the "AI VDB Provider (PostgreSQL)" server, a Drupal\ai_vdb_provider_postgres\Exception\InsertIntoCollectionException is thrown.

This error specifically occurs when a 'select string' type field (such as a text list field) is configured, and the "Filterable attributes" option is selected in the field's settings within the Search API index.

The generated INSERT query does not enclose string values in single quotes, causing PostgreSQL to interpret them as column names instead of string literals. This leads to the "column does not exist" error.

Steps to Reproduce:

  1. Ensure the search_api, search_api_db (or your chosen storage provider), and ai_vdb_provider_postgres modules are installed and enabled.
  2. Create a new Search API server of type "AI VDB Provider (PostgreSQL)" and configure it correctly.
  3. Create a new Search API index and associate it with the VDB Provider server created in step 2.
  4. Add a field to the index that is of 'select string' type and can contain multiple values (e.g., a text list field allowing multiple values).
  5. In the field's configuration within the Search API index (at /admin/config/search/search-api/index/[your_index]/fields), expand the "Index options" section and ensure the "Filterable attributes" select is marked.
  6. Create or edit content that has multiple values for the field configured in step 4 (e.g., a node with a "season of the year" field that has values like 'primavera', 'otono', 'invierno').
  7. Attempt to index the content, either through the Search API UI or via Drush (e.g., drush search-api:index).

Expected Behavior:

The content should be indexed successfully without SQL errors. The string values ('primavera', 'otono', 'invierno') should be correctly inserted into the table, enclosed in single quotes within the INSERT query.

Actual Behavior:

The indexing process fails with the following exception and error message:

Drupal\ai_vdb_provider_postgres\Exception\InsertIntoCollectionException: ERROR: column "primavera" does not exist LINE 1: ...NTO "pois__year_season" (value, chunk_id) values (primavera,... ^ in Drupal\ai_vdb_provider_postgres\PostgresPgvectorClient->insertIntoCollection() (line 213 of /var/www/html/web/modules/contrib/ai_vdb_provider_postgres/src/PostgresPgvectorClient.php).

The generated SQL query causing the error is:

INSERT INTO "pois__year_season" (value, chunk_id) values (primavera, currval('"pois_id_seq"')),(otono, currval('"pois_id_seq"')),(invierno, currval('"pois_id_seq"'));

As observed, the values primavera, otono, invierno are not enclosed in single quotes, leading PostgreSQL to interpret them as non-existent column names.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇪🇸Spain aarnau

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