Skip to main content
Version: 11.14.0

Suggest

The Suggest module provides functions to retrieve search suggestions from the backend, based on user input text. It supports suggestion queries, field-based suggestions, and filtering by kind.

Functions

fetchSuggest()

Fetches suggestions from a named suggest query based on the provided text.

Parameters

ParameterTypeRequiredDescription
suggestQueryNamestringName of the suggest query configured on the server
textstringThe text for which to fetch suggestions
filterRecord<string, unknown>Optional filter object. Keys are column names declared in the suggestion lexicon's filter columns section.
kindsstring[]Optional array of suggestion kinds to restrict results. Overrides the kinds defined in the suggest query.
showSourcebooleanIf true, includes the source index column name in each suggestion

Returns Promise<Suggestion[]> — array of suggestions.

Example

fetch-suggest.ts
import { fetchSuggest } from '@sinequa/atomic';

// Basic suggestion
const suggestions = await fetchSuggest('_suggest', 'sinequa');

// With kind filter
const peopleSuggestions = await fetchSuggest('_suggest', 'john', undefined, ['person']);

// With column filter
const filteredSuggestions = await fetchSuggest('_suggest', 'report', {
docformat: 'doc'
}, ['city', 'name']);

fetchSuggestField()

Fetches suggestions for specific index fields based on the provided text.

Parameters

ParameterTypeRequiredDescription
textstringThe text for which to fetch field suggestions
fieldsstring[]List of index field names to suggest from
queryQueryOptional query context to refine suggestions

Returns Promise<Suggestion[]> — array of field-based suggestions.

Example

fetch-suggest-field.ts
import { fetchSuggestField } from '@sinequa/atomic';

const suggestions = await fetchSuggestField('tesla', ['title', 'authors']);
suggestions.forEach(s => console.log(s.display));

fetchSuggestQuery()

Deprecated

Use fetchSuggest() instead.

Fetches suggestions based on a query name and optional field kinds.

Parameters

ParameterTypeRequiredDescription
suggestQueryNamestringName of the suggest query
textstringThe text for which to fetch suggestions
queryNamestringThe name of the associated query
fieldsstring | string[]Optional array or comma-separated list of kinds to filter suggestions

Returns Promise<Suggestion[]> — array of suggestions.