I can query a milvus vector database like this
val relevant: List<EmbeddingMatch<TextSegment>> = milvusEmbeddingStore.findRelevant(queryEmbedding, 10)
So I then get a list of documents with ids. Can I somehow request one of these documents by it's id? Or by a metadata property?
Yes, but seems langchain4j doesn't include the ability. You can use the query()
method of the Milvus Java SDK, link to doc. I assume langchain4j has already included the Milvus Java SDK in its dependencies so you don't need to worry about introducing a new one.
Actually langchain4j is already using this query()
method itself but only to retrieve the raw embeddings as a side effect of searching for docs and does not expose it externally. See here. All you need to do is to add TEXT_FIELD_NAME
into the output fields list.