Skip to content

similaritySearch throwing Exception due to schema name #4130

@lasficw

Description

@lasficw

Bug description
When doing a similaritySearch using the VectorStore on a database where the schema name contains a - i run into an exception.

PreparedStatementCallback; bad SQL grammar [SELECT *, embedding <=> ? AS distance FROM demo-1998.vector_store WHERE embedding <=> ? < ?  AND metadata::jsonb @@ '($.entityType == "PROCESS" ...)'::jsonpath  ORDER BY distance LIMIT ? ]

I'm pretty sure that it is related to the schema name here. A possible fix could be wrapping the schema name in " on SpringAI side.

Environment
Dependencies using Spring Boot 3.5.4 and Java 20

implementation("org.springframework.ai:spring-ai-starter-mcp-server-webmvc")
implementation("org.springframework.ai:spring-ai-starter-model-azure-openai")
implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector")

Steps to reproduce

  • Do a similaritySearch call on a database schema which has a - in its name

Expected behavior
No exceptions are thrown

Minimal Complete Reproducible example

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions