[Qdrant] Hardcoded "doc_content" field name in QdrantVectorStore causes IllegalArgumentException when retrieving documents
Description I am using Spring AI (v1.1.2) with Qdrant for RAG implementation. In my Qdrant collection, the document text is stored in the standard content field within the payload.
However, when performing a similaritySearch, the application throws an IllegalArgumentException. Upon debugging, it appears that QdrantVectorStore expects the payload key to be "doc_content" instead of "content". Since the key does not match, the content is retrieved as null, causing the validation in the Document constructor to fail.
It seems there is no easy way to configure this field name via application.yml properties in the current auto-configuration.
Environment Spring AI Version: 1.1.2 Spring Boot Version: 3.4.2 (Please adjust if different) Java Version: 21
Steps to Reproduce Insert a vector into Qdrant with a payload structure like:
{ "payload": { "content": "This is a test document", "some_metadata": "value" } } Execute a similarity search using QdrantVectorStore.
Java
List
Actual Behavior / Stack Trace The toDocument method fails to map the payload content to the Document object.
Plaintext
java.lang.RuntimeException: java.lang.IllegalArgumentException: exactly one of text or media must be specified
at org.springframework.ai.vectorstore.qdrant.QdrantVectorStore.toDocument(QdrantVectorStore.java:288)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
...
Caused by: java.lang.IllegalArgumentException: exactly one of text or media must be specified
at org.springframework.util.Assert.isTrue(Assert.java:116)
at org.springframework.ai.document.Document.
Java // The key is hardcoded or defaults to "doc_content" String content = (String) metadata.remove("doc_content"); Since my database uses "content", the content variable becomes null, triggering the assertion error in the Document builder.
Suggested Fix Make the content field name configurable: Expose a property (e.g., spring.ai.vectorstore.qdrant.content-field-name) in the QdrantVectorStoreAutoConfiguration so users can specify their payload key (e.g., "content", "text", "page_content").
Update Default: Consider changing the default back to "content" as it is a common standard, or implement a fallback mechanism.
Currently, I have to workaround this by creating a custom class to shadow QdrantVectorStore or manually defining the Bean with a modified constructor (if available).
Hi, I would like to work on this issue.
It seems like the hardcoded "doc_content" field name is causing the issue. I plan to fix this by making it consistent with the Document content field or making it configurable.
Could you please assign this issue to me?
This looks resolved since 2.0.0-M2: f65756ee2 makes the payload key configurable, with QdrantVectorStore.builder(...).contentFieldName("content") or the spring.ai.vectorstore.qdrant.content-field-name property; the default stays doc_content. #3797 asks for the same. Could this issue be closed?