in src/features/chat-page/chat-services/azure-ai-search/azure-ai-search.ts [159:183]
for await (const result of searchResults.results) {
const item = {
score: result.score,
document: result.document,
};
// exclude the all the fields that are not in the fields array
const document = item.document as any;
const newDocument: any = {};
// iterate over the object entries in document
// and only include the fields that are in the fields array
for (const key in document) {
const hasKey = vectors.includes(key);
if (!hasKey) {
newDocument[key] = document[key];
}
}
results.push({
score: result.score,
document: newDocument, // Use the newDocument object instead of the original document
});
}