Exception: Collection name is required by Milvus in Drupal\openai_embeddings\Plugin\openai_embeddings\vector_client\Milvus->query() (line 68 of

Created on 7 April 2024, 7 months ago
Updated 8 April 2024, 7 months ago

PHP 8.2, openai and search_api_ai modules are both the latest dev version.

When I post a chat in the Search API AI chat block form, the error occured as below:
Exception: Collection name is required by Milvus in Drupal\openai_embeddings\Plugin\openai_embeddings\vector_client\Milvus->query() (line 68 of /var/www/html/drupal/web/modules/contrib/openai/modules/openai_embeddings/src/Plugin/openai_embeddings/vector_client/Milvus.php).

I modifed and hardcoded the optional collection key to the one exactly "drupal" set on the page /admin/config/search/search-api/server/my_milvus:
modules/milvus/src/Plugin/search_api/backend/SearchApiMilvusBackend.php

    $response = $this->client->query([
      'vector' => $query->getOption('query_embedding'),
      'top_k' => $query->getOption('top_k'),
      //'collection' => $query->getOption('collection'),
      'collection' => 'drupal',

Then other error occured as below:
TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 178 of /var/www/html/drupal/web/modules/contrib/search_api_ai/modules/milvus/src/Plugin/search_api/backend/SearchApiMilvusBackend.php).

It seemed no results return from Milvus server. However, when I run and it returned data as below:

curl -X 'GET' \
  'http://localhost:9091/api/v1/collection' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "collection_name": "drupal"
  }'
{"status":{},"schema":{"name":"drupal","fields":[{"fieldID":100,"name":"id","is_primary_key":true,"data_type":5,"autoID":true},{"fieldID":101,"name":"vector","data_type":101,"type_params":[{"key":"dim","value":"1536"}]}],"enable_dynamic_field":true},"collectionID":448412325705664577,"virtual_channel_names":["by-dev-rootcoord-dml_2_448412325705664577v0"],"physical_channel_names":["by-dev-rootcoord-dml_2"],"created_timestamp":448896252819800071,"created_utc_timestamp":1712403308181,"shards_num":1,"consistency_level":2,"collection_name":"drupal","db_name":"default","num_partitions":1}
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇳China fishfree

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

Comments & Activities

Production build 0.71.5 2024