GeniusResultContext - Scoped
-
- UpdatedJan 30, 2025
- 6 minutes to read
- Yokohama
- API reference
The GeniusResultContext API provides methods for retrieving search query information from the context of a Genius Result configuration.
You can use search query details retrieved with this API to populate Genius Result answer objects created with the GeniusResultAnswer API.
Use this API in Genius Result server-side scripts with the sn_ais
namespace
identifier. For more information on scripting logic for Genius Results, see Create a new Genius Result
configuration.
GeniusResultContext - getMatchingDocuments()
Retrieves search result documents from the search query that triggers your Genius Result configuration.
Name | Type | Description |
---|---|---|
None |
Example
This AI Search response processor script retrieves up to three search result documents matched by the search query and checks whether any of them is from the Knowledge [kb_knowledge] table. If it finds a search result document from the Knowledge table, the function adds that document's fields to the GeniusResultAnswer object so the UI can display them to the user.
GeniusResultContext – getOriginalSearchPhrase()
Retrieves the original search terms from the search query that triggers your Genius Result configuration.
You can use retrieved search terms to populate Genius Result answers using GeniusResultAnswer API methods.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
String | Original terms from the search query. Data type: String |
Example
This AI Search request processor script gets the search query's original terms and uses them as the query terms for a new snippet search.
GeniusResultContext – getPredictionResult()
Retrieves NLU model prediction results for the search query that triggers your Genius Result configuration.
Use this method in a Genius Result configuration's request or response processor script to retrieve the intent detected for the triggering search query. You can populate Genius Result answers with details from the detected intent using GeniusResultAnswer API methods.
Name | Type | Description |
---|---|---|
None |
Example
This AI Search request processor script checks whether the search query includes an NLU model prediction result. When it finds a prediction result, it adds the matching segments from all detected catalogItem entities as search terms.