Skip to main content
Version: 11.14.0

Text Chunk

The TextChunkService retrieves text chunks from the Sinequa backend for a given document and set of highlight locations.

Methods

getTextChunks()

Fetches text chunks with surrounding context sentences and highlights.

getTextChunks(
id: string,
textChunks: TextLocation[],
highlights: string[],
query: Query,
leftSentencesCount: number,
rightSentencesCount: number
): Observable<TextChunk[]>
NameTypeRequiredDescription
idstringThe ID of the record.
textChunksTextLocation[]Text locations within the document.
highlightsstring[]Highlight category names to apply.
queryQueryThe query used to retrieve the chunks.
leftSentencesCountnumberNumber of sentences to include before each chunk.
rightSentencesCountnumberNumber of sentences to include after each chunk.

Returns Observable<TextChunk[]> — emits the retrieved text chunks.

Example

example.component.ts
import { inject } from '@angular/core';
import { TextChunkService } from '@sinequa/atomic-angular';

inject(TextChunkService).getTextChunks(
'recordId',
[{ start: 0, end: 100 }],
['extractslocations', 'matchlocations'],
query,
2,
2
).subscribe(chunks => {
console.log(chunks);
});