A corpus is a collection of documents or data assembled so a retrieval system can search it for context relevant to a prompt. In RAG, the corpus supplies the material added to an LLM request instead of requiring every document to be included manually. section 10.2.1 section 11.1
A useful corpus supports retrieval by providing:
- Relevant documents, such as labeled HTML pages, code, documentation, database entries, raw metrics, or user stories. section 10.2.1 section 11.2.1
- A retrieval process that compares a query with corpus items and selects the closest match for prompt insertion. section 11.1 section 11.2.1
- A relevance rule that limits context to useful documents, helping avoid context-window limits and irrelevant prompt content. section 11.1 section 10.2.1
Testing-risk corpus
A folder of user-story text files can form a corpus for a testing assistant. Given “I want test ideas for deleting bookings,” retrieval can select the story describing a DELETE request with a booking ID, status codes, and optional cookie authentication. The selected story is inserted into a prompt that asks an LLM to suggest testing risks. section 11.1 section 11.2.1
public static List<String> loadFilesFromResources(String folderPath) #1
➥throws IOException { #1
List<String> fileContents = new ArrayList<>(); #1
ClassLoader classLoader = CompletedRAGDemo.class.getClassLoader(); #2
File folder = new File(classLoader.getResource(folderPath).getFile()); #2
for (File file : folder.listFiles()) { #3
if (file.isFile()) { #3
String fileContent = FileUtils.readFileToString(file, "UTF-8"); #3
fileContents.add(fileContent); #3
} #3
} #3
return fileContents; #4
}
The listing shows a Java method that loads every file from a resources folder into a list, creating a simple document corpus for later querying. section 11.2.1



