spring-projects / spring-projects/spring-ai

pgvector initialization failure

Open
#3,407 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
Error when manually configuring pgvector。
bug : ERROR: no schema has been selected to create in

Environment



org.springframework.ai
spring-ai-bom
1.0.0
pom
import


<dependencies>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-vector-store-pgvector</artifactId>
    </dependency>

    <!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
    <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.57</version>
        <exclusions>
            <exclusion>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-model-zhipuai</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-vector-store</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jackson-core</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-mcp-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-rag</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-advisors-vector-store</artifactId>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.30</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>3.4.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-starter-model-chat-memory-repository-jdbc</artifactId>
    </dependency>
</dependencies>

Steps to reproduce
@Bean
public DataSource myDataSource(){
DataSource root = DataSourceBuilder.create()
.url("jdbc:postgresql://117.72.36.124:5432/spring-ai?currentSchema=public")
.username("postgres")
.password("postgres")
.build();
return root;
}

@Bean
public VectorStore vectorStore(@Qualifier ("myDataSource") DataSource myDataSource, ZhiPuAiEmbeddingModel embeddingModel) {
     JdbcTemplate jdbcTemplate = new JdbcTemplate(myDataSource);
    return PgVectorStore.builder(jdbcTemplate, embeddingModel)
            .dimensions(2048)                    // Optional: defaults to model dimensions or 1536
            .distanceType(COSINE_DISTANCE)       // Optional: defaults to COSINE_DISTANCE
            .indexType(HNSW)                     // Optional: defaults to HNSW
            .initializeSchema(true)              // Optional: defaults to false
            .schemaName("public")                // Optional: defaults to "public"
            .vectorTableName("vector_store")     // Optional: defaults to "vector_store"
            .maxDocumentBatchSize(10000)         // Optional: defaults to 10000
            .build();
}

spring.ai.vectorstore.type=false

Expected behavior

Wish to tell me how should I configure schema,or is this a misbehavior?

log.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PgVectorStore.builder configuration in the reproduction and inspect log.txt for the failing schema initialization statement. Determine whether schemaName("public") and initializeSchema(true) should prevent the PostgreSQL error; done means establishing whether this is a configuration issue or a PgVectorStore initialization bug.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, postgresql, spring-boot
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.