Skip to main content

Fetch Similar Documents

Overview

This module provides functionality for retrieving documents that are similar to a given document. It allows users to:

  • Fetch similar documents based on a specified document ID and query name

These operations enable efficient retrieval of related documents, enhancing user experience in search and discovery scenarios.

fetchSimilarDocuments()

Fetches similar documents based on the provided document ID and query name.

ParameterTypeDescription
documentIdstringThe ID of the document to compare against.
queryNamestringThe name of the query to use for comparison.

Returns A promise that resolves to an object containing an array of Article objects and a methodresult string.

Example

import { fetchSimilarDocuments } from '@sinequa/atomic';

// Example 1: Fetch similar documents using a document ID and query name
async function exampleFetchSimilarDocuments() {
try {
const documentId = '12345';
const queryName = 'similarityQuery';
const result = await fetchSimilarDocuments(documentId, queryName);
console.log('Similar Documents:', result.data);
console.log('Method Result:', result.methodresult);
} catch (error) {
console.error('Error fetching similar documents:', error);
}
}

exampleFetchSimilarDocuments();