Skip to content

ElasticsearchVectorStore create error #3387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yulang1992 opened this issue May 30, 2025 · 1 comment
Closed

ElasticsearchVectorStore create error #3387

yulang1992 opened this issue May 30, 2025 · 1 comment
Assignees

Comments

@yulang1992
Copy link

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: 'co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty$Builder co.elastic.clients.elasticsearch._types.mapping.DenseVectorProperty$Builder.similarity(java.lang.String)', I check the source code,A type mismatch was found.

Image

Environment

<properties>
    <java.version>21</java.version>
    <spring-ai.version>1.0.0</spring-ai.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- mongodb nosql chat memory -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>


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

</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.ai</groupId>
            <artifactId>spring-ai-bom</artifactId>
            <version>${spring-ai.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>

</build>

Steps to reproduce
Steps to reproduce the issue.

Expected behavior

  public final Builder similarity(@Nullable DenseVectorSimilarity value) {
        this.similarity = value;
        return this;
    }

private void createIndexMapping() {
	try {
		this.elasticsearchClient.indices()
			.create(cr -> cr.index(this.options.getIndexName())
				.mappings(map -> map.properties(this.options.getEmbeddingFieldName(),
                                                 //    In fact  	p -> p.denseVector(dv -> dv.similarity(this.options.getSimilarity().toString())
						p -> p.denseVector(dv -> dv.similarity(this.options.getSimilarity())
							.dims(this.options.getDimensions())))));
	}
	catch (IOException e) {
		throw new RuntimeException(e);
	}
}
@ilayaperumalg ilayaperumalg self-assigned this May 30, 2025
@ilayaperumalg
Copy link
Member

@yulang1992 Looks like the elastic search java client you are using isn't compatible with the version Spring AI 1.0.0 brings in - 8.15.5. You need to enforce your application to use this specific version of elastic search java client to make this work.

Please feel free to re-open the issue if you still see the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants