Skip to content

Example (DocumentLoader with Field Data)

Serdar Basegmez edited this page Jun 13, 2025 · 2 revisions
// Ingestor will combine the model+store+splitter
EmbeddingStoreIngestor ingestor = EmbeddingStoreIngestor.builder()
                                                        .embeddingModel(embeddingModel)
                                                        .embeddingStore(embeddingStore)
                                                        .documentSplitter(DocumentSplitters.recursive(8196, 256))
                                                        .build();

// Prepare a metadata: Add Subject on top of default metadata
var metadataDef = MetadataDefinition.builder(MetadataDefinition.DEFAULT)
                                    .addString("Subject")
                                    .build();

// Prepare list of Documents
// Note that Document here is not Domino Document.
List<Document> docs = DominoDocumentLoader.create(metadataDef)    // Use custom metadata
                                          .database(database)     // Use given Notes database
                                          .noteIds(docIds)        // Load the list of note ids
                                          .fieldName("Subject")   // Subject and Body fields will be used to extract text
                                          .fieldName("Body")      // Document loader will join fields by new line.
                                          .loadDocuments();       // Load all into a list

// Start ingesting in parallel threads
docs.parallelStream().forEach(ingestor::ingest);

Refer to IngestNotesHelp.java for the complete code.

Clone this wiki locally