Skip to content
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

OpenSearch Client manual config #2325

Open
giocorito opened this issue Feb 26, 2025 · 0 comments
Open

OpenSearch Client manual config #2325

giocorito opened this issue Feb 26, 2025 · 0 comments

Comments

@giocorito
Copy link

First of all, thanks in any case.
I hope to be so clear in my issue details to help you finding a solution as soon as possible.

Giorgio

Bug description

Use Case
Use OpenSearch as VectorStore DB with manual config.
When I try to create a OpenSearchClient, I need two items:

  • transport [instance of org.opensearch.client.transport.rest_clien.RestClientTransport]
  • options [instance of org.opensearch.client.transport.TransportOptions]

When I try to create a RestClientTransport, I need two items:

  • restClient [instance of org.opensearch.client.RestClient]
  • mapper [instance of org.opensearch.client.json.JsonpMapper]

Failure
I can't create an instance of org.opensearch.client.RestClient because of the class is in dependencies set, but is not visible in IDE due to duplicate package name:

1. package org.opensearch.client in dependency opensearch-java-2.10.1.jar
2. package org.opensearch.client in dependency opensearch-rest-client-2.12.0.jar

The order is the same order in gradle dependency list
The first package hides the second one, so org.opensearch.client.RestClient (opensearch-rest-client-2.12.0.jar) is not visible.

Environment

IDE details

IntelliJ IDEA 2024.3.3 (Community Edition)
Build #IC-243.24978.46, built on February 11, 2025

Runtime version: 21.0.6+8-b631.39 aarch64 (JCEF 122.1.9)
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

Gradle version (local install): 8.12
Maven version (bundle): 3.9.9

build.gradle details

plugins {
	id 'java'
	id 'org.springframework.boot' version '3.3.5'
	id 'io.spring.dependency-management' version '1.1.6'
	//id 'org.jsonschema2pojo' version '1.2.2'
}

java {
	toolchain {
		languageVersion = JavaLanguageVersion.of(17)
	}
}

repositories {
	mavenCentral()
	maven { url 'https://repo.spring.io/milestone' }
	maven { url 'https://repo.spring.io/snapshot' }
}

ext {
	// verison of spring BOM
	set('springAiVersion', "1.0.0-SNAPSHOT")
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	implementation 'org.springframework.boot:spring-boot-starter-freemarker'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
	implementation 'org.apache.commons:commons-lang3:3.14.0'
	implementation 'org.springframework.ai:spring-ai-openai'
	implementation 'org.springframework.ai:spring-ai-opensearch-store'
	compileOnly 'org.projectlombok:lombok:1.18.34'
	annotationProcessor 'org.projectlombok:lombok:1.18.34'
	implementation 'ch.qos.logback.contrib:logback-json-classic:0.1.5'
	implementation 'ch.qos.logback.contrib:logback-jackson:0.1.5'
	// support for Java 8 date/time type java.time.LocalDate not supported by default
	implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
}

dependencyManagement {
	imports {
		mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
	}
}

Steps to reproduce
Create a simple SpringBoot project and try to use OpenSearch as vector db with manual config

Expected behavior
Use the OpenSearch library with manual configuration, as showed in https://docs.spring.io/spring-ai/reference/api/vectordbs/opensearch.html

Minimal Complete Reproducible example

	restClient -> instance of org.opensearch.client.RestClient (desiderata) 
        JacksonJsonpMapper mapper = new JacksonJsonpMapper();
        RestClientTransport transport = new RestClientTransport(restClient,mapper);

        TransportOptions options = TransportOptions.builder().build();
        OpenSearchClient client = new OpenSearchClient(transport, options);
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

1 participant