I am getting this error while trying to persist embeddings into elastic search. I am taking a file using post call in spring boot app and then using langchain4j elasticsearch embedding store trying to add embeddings.
attaching code
@PostMapping(“/hellofile”)
public String fs(@RequestParam(“file”) MultipartFile file) throws IOException {
String content = new String(file.getBytes());
newAssistant = rag.newAssistant2(content);
return "hello user! I am good to go you may ask questions now";
}
this is how embedding are getting generated
DocumentSplitter splitter = DocumentSplitters.recursive(300, 0);
Document document = Document.from(file);
List<TextSegment> segments = splitter.split(document);
EmbeddingModel embeddingModel = new BgeSmallEnV15QuantizedEmbeddingModel();
List<Embedding> embeddings = embeddingModel.embedAll(segments).content();
this is how embedding are getting store
EmbeddingStore embeddingStore = ElasticsearchEmbeddingStore.builder()
.serverUrl(“https://localhost:9200”).userName(“elastic”).password(“changeit”)
.indexName(“indexsa”).dimension(2)
.build();
embeddingStore.addAll(embeddings, segments);
I am expecting embeddigs to be store in db
iamarjav is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.