Atomic Angular — Doc interne

Text Chunk

Fetch surrounding-context text chunks for a document's highlight locations, from the Sinequa backend.

TextChunkService retrieves text chunks — a highlight location plus a configurable number of sentences of context on either side — for a given document. Used where a preview needs to show highlighted passages without loading the whole converted document.

Minimal example

Fetching two chunks of context around a match
passage-context.component.ts
import { Component, inject } from "@angular/core";
import { TextChunkService } from "@sinequa/atomic-angular";
import type { Query } from "@sinequa/atomic";

@Component({
  selector: "passage-context",
  template: `<button (click)="load()">Load context</button>`,
})
export class PassageContextComponent {
  private readonly textChunkService = inject(TextChunkService);

  protected load() {
    const query: Query = { name: "my-query", text: "quarterly report" };

    this.textChunkService
      .getTextChunks("doc-42", [{ offset: 0, length: 100 }], ["extractslocations", "matchlocations"], query, 2, 2)
      .subscribe(chunks => console.log(chunks));
  }
}

Options

Prop

Type

getTextChunks(...) returns Observable<TextChunk[]>.

Pitfalls

What's next

On this page