Skip to content

Commit e7d8a51

Browse files
san.kimsan.kim
authored andcommitted
GH-3609: Fail fast on media-only Document in QdrantVectorStore
* Throw IllegalArgumentException when Document.isText() is false Signed-off-by: san.kim <[email protected]>
1 parent 089c3eb commit e7d8a51

File tree

1 file changed

+9
-1
lines changed
  • vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant

1 file changed

+9
-1
lines changed

vector-stores/spring-ai-qdrant-store/src/main/java/org/springframework/ai/vectorstore/qdrant/QdrantVectorStore.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,16 @@ private Document toDocument(ScoredPoint point) {
296296
*/
297297
private Map<String, Value> toPayload(Document document) {
298298
try {
299+
String documentContent = document.getText();
300+
if(!document.isText()) {
301+
throw new IllegalArgumentException("""
302+
QdrantVectorStore supports only text-based Document for now –
303+
received media-only Document; see issue #3609.
304+
""");
305+
}
306+
299307
var payload = QdrantValueFactory.toValueMap(document.getMetadata());
300-
payload.put(CONTENT_FIELD_NAME, io.qdrant.client.ValueFactory.value(document.getText()));
308+
payload.put(CONTENT_FIELD_NAME, io.qdrant.client.ValueFactory.value(documentContent));
301309
return payload;
302310
}
303311
catch (Exception e) {

0 commit comments

Comments
 (0)