DictionaryFieldContext (Search Engine)
DictionaryFieldContext (Search Engine)
In this article
|
Note
This component was introduced in version |
Example implementation
dictionary-field-context.fn.ts
import {buildDictionaryFieldContext} from '@coveo/headless';
import {useContext} from 'react';
import {AppContext} from '../../context/engine';
export function DictionaryFieldContext() {
const {engine} = useContext(AppContext);
const ctx = buildDictionaryFieldContext(engine!);
ctx.set({price_currency: 'fr', price_discounted: 'fr'});
return null;
}
The DictionaryFieldContext
controller allows specifying which dictionary field keys to retrieve.
Methods
add
Adds (or, if one is already present, replaces) a new dictionary field context key-value pair.
Parameters
-
field:
string
The dictionary field name.
-
key:
string
The dictionary field key for which to retrieve a value.
set
Sets the dictionary field context for the query. This replaces any existing context with the new one.
Parameters
-
context:
Record<string, string>
The dictionary field context to set for the query.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => void
A callback that’s invoked on state change.
Returns Unsubscribe
: A function to remove the listener.
Was this article useful?
Thanks for your feedback!