Skip to main content
Version: 11.14.0

Export

The Export module provides a function to export query results in various formats (CSV, XLSX, etc.) from the Sinequa backend.

Functions

fetchQueryExport()

Exports query results according to the provided model and returns the raw Response for download handling.

Parameters

ParameterTypeRequiredDescription
modelExportQueryModelExport configuration (format, columns, limits, etc.)
appNamestringThe Sinequa application name
queryQueryThe query whose results should be exported
articleArticleOptional article associated with the query (for selection exports)

Returns Promise<Response> — the raw HTTP response. Use .blob() or .text() to access the file content.

ExportQueryModel type
type ExportQueryModel = {
export: ExportSourceType; // 'Result' | 'Selection' | ...
format: ExportOutputFormat; // 'Csv' | 'Xlsx' | ...
webservice: string;
maxcount: number;
exportedColumns: string[];
filename?: string;
};

Example

export-query.ts
import { fetchQueryExport } from '@sinequa/atomic';

const model = {
export: 'Result' as const,
format: 'Csv' as const,
webservice: 'training_export',
maxcount: 100,
exportedColumns: ['Title', 'Filename', 'Url'],
filename: 'results.csv'
};

const response = await fetchQueryExport({
model,
appName: 'training',
query: { name: '_query', text: 'hello world' }
});

// Download the file
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = model.filename ?? 'export.csv';
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);