Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class ElasticsearchStore implements VDBStoreBase, AutoCloseable {
private static final String FIELD_DOC_ID = "doc_id";
private static final String FIELD_CHUNK_ID = "chunk_id";
private static final String FIELD_CONTENT = "content";
private static final String FIELD_PAYLOAD = "payload";

private final String indexName;
private final int dimensions;
Expand Down Expand Up @@ -404,6 +405,10 @@ private Map<String, Object> mapToEsDocument(Document doc) {
DocumentMetadata meta = doc.getMetadata();
map.put(FIELD_DOC_ID, meta.getDocId());
map.put(FIELD_CHUNK_ID, meta.getChunkId());
Map<String, Object> customPayload = meta.getPayload();
if (customPayload != null && !customPayload.isEmpty()) {
map.put(FIELD_PAYLOAD, meta.getPayload());
}

// Serialize ContentBlock to JSON string to ensure safe storage/retrieval
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ void testAddDimensionMismatch() throws VectorStoreException {
.verify();
}

@Test
@DisplayName("Should add documents with payload")
void testAddPayload() throws VectorStoreException {
store = createMockStoreForAdd(true);

TextBlock content = TextBlock.builder().text("Test content").build();
DocumentMetadata metadata =
new DocumentMetadata(content, "doc-1", "chunk-1", Map.of("k", "v"));
Document doc = new Document(metadata);
doc.setEmbedding(new double[TEST_DIMENSIONS]);

StepVerifier.create(store.add(List.of(doc))).verifyComplete();
}

// ==================== Search Method Tests ====================

@SuppressWarnings("unchecked")
Expand Down
Loading