Integrating in Application
This section is intended for application developers to integrate Trusted Answer Search into their application and build a natural-language interface. The integration can be done in the following ways:
-
Portal APEX App A pre-built, end-user facing application that performs search on Trusted Answer Search. Enterprise developers can deploy this app to provide search or chatbot functionality for their end-users.
-
Search Widgets Pre-built JavaScript widgets that add a search bar or floating search icon to an existing web page. The widgets call Trusted Answer Search through Oracle REST Data Services (ORDS).
-
PL/SQL Search API If enterprise developers do not use the pre-built APEX Portal App, they can call the DBMS_TRUSTED_SEARCH.SEARCH() PL/SQL procedure directly or invoke it through an ORDS REST endpoint.
APEX Portal Experience
Deploy the Trusted Answer Search portal application when you want to provide a stand-alone search experience for end-users without building a custom UI from scratch.
-
Administrator setup Your Trusted Answer Search administrator must install the portal app that ships in the installation archive. The setup script provisions the APEX application and makes the portal available at a dedicated URL.
-
Authorize end-users Search Space Experts (or Search Administrators) must grant each end-user access to the appropriate search space inside the admin app. Only authorized users can sign in to the portal.
-
Share or link to the portal Application developers can either:
- Add a link or button in their website that redirects users to the hosted portal URL, or
- Communicate the direct portal link (for example via email or in-product messaging) so users can access it on demand.
What end-users see
-
Portal app sign-in
Launch the portal application in a fresh session and sign in with
tasuser / tasuser.
-
Search results in the WIKIMEDIA space
After login, pick WIKIMEDIA from the Search Space menu, type
italian page viewsinto the question box, and submit the search. The results show Wikimedia page-view targets that match the query. Trusted Answer Search extracts values from the query and displays target inputs such aslanguage: it, along with configured values such asperiod: 2-year,project: wikipedia, andfrequency: monthly.
Search Widgets
Use the Trusted Answer Search widgets when you want to embed search directly into an existing application page without building a custom search interface. The widget package includes:
- Search Bar: a compact inline search box that can be placed in a page header, navigation area, or application page.
- Search Icon: a floating launcher that opens a conversational search panel.
Both widgets use the same ORDS-backed search endpoint and the same configuration attributes. You can deploy either widget independently of the APEX portal application.
Administrator Setup
Before application developers embed a widget, a Trusted Answer Search administrator must install and verify the widget REST endpoints.
-
Verify prerequisites Confirm that the Trusted Answer Search back-end components are installed and that Oracle REST Data Services is available for the database. On Autonomous AI Database Cloud Services (ADB-S), ORDS is available by default. For on-premises deployments, install and configure ORDS before running the widget installer.
-
Extract the widget package From the Trusted Answer Search release archive, extract
widget_ship.zip. -
Configure the widget installer Edit
install_widget.confand provide the database connection, installer user, andTASADMINpassword. The installer user must have the privileges required to create the ORDS-backed REST objects.Example:
DB_CONNECT_STRING='myadb_high' INSTALLER_USER=ADMIN INSTALLER_USER_PASSWORD=<admin_password> TASADMIN_PASSWORD=<tasadmin_password> -
Configure JWT authentication for production deployments To protect the search endpoints, configure the JWT parameters in
install_widget.conf. IfJWT_ISSUER,JWT_AUDIENCE, andJWT_JWK_URLare not set together, the endpoints are installed without JWT protection.JWT_ISSUER=https://identity.oraclecloud.com/ JWT_AUDIENCE=https://myadb-host.adb.us-phoenix-1.oraclecloudapps.com/ords/trusted-search/ JWT_JWK_URL=https://idcs-example.identity.oraclecloud.com:443/admin/v1/SigningCert/jwk JWT_SCOPE_NAME=search_accessFor production or internet-facing deployments, configure JWT authentication so search requests run under an authenticated user identity. Without JWT authentication, any client that can reach the endpoint can call it.
-
Run the widget installer
cd widget_ship ./install_widget.sh --config install_widget.confThe installer registers the widget REST endpoints under
<ORDS_BASE_URL>/trusted-search/search-api/. -
Verify endpoint access Use the
identity/endpoint to confirm that the endpoint is reachable and that JWT identity resolution works when JWT authentication is configured.curl -i -H "Authorization: Bearer <ACCESS_TOKEN>" \ "https://<adb-host>/ords/trusted-search/search-api/identity/"A successful authenticated response includes the resolved user identity:
{ "remote_ident": "user@example.com", "tas_ctx_username": "user@example.com", "tas_ctx_source": "ORDS", "client_identifier": "user@example.com", "session_user": "TASADMIN", "apex_app_user": null }
Application Developer Setup
After the administrator installs and verifies the widget endpoints, application developers can host the widget files and embed them into target pages.
-
Host the widget JavaScript files From
widget_ship.zip, copy one or both widget files to a web server or static asset location that your application can load:search_bar_widget.jssearch_icon_widget.js
Serve the files over HTTPS when the application page is served over HTTPS.
-
Embed the widget Add the script tag for the widget you want to use. Set
data-ords-search-urlto the Trusted Answer Search ORDS search endpoint anddata-search-spaceto the search space that users should query.Inline Search Bar:
<script src="/assets/js/search_bar_widget.js" data-ords-search-url="https://your-host.example.com/ords/trusted-search/search-api/search/" data-search-space="wikimedia"> </script>Floating Search Icon:
<script src="/assets/js/search_icon_widget.js" data-ords-search-url="https://your-host.example.com/ords/trusted-search/search-api/search/" data-search-space="wikimedia"> </script>On ADB-S, find the ORDS base URL on the database details page under Tool Configuration, Web Access (ORDS), Public access URL.
The following image shows an example of embedding the Search Bar widget in a Wikimedia Insights application page:

-
Provide the end-user token when JWT is enabled If the administrator enabled JWT authentication for the widget endpoints, the host application must obtain an access token for the signed-in end user and include it as a bearer token when the widget calls the ORDS search endpoint. Use an end-user authorization flow, such as Authorization Code. Do not use a client credentials token for user-facing widget searches because it represents the client application, not the end user.
-
Optionally configure widget display Define
window.SEARCH_WIDGET_CONFIGbefore loading the widget script to customize display settings.<script> window.SEARCH_WIDGET_CONFIG = { showTargetInputs: true, placeholder: "Powered by Oracle Trusted Answer Search", debounceMs: 150 }; </script>Supported options are:
showTargetInputs: set totrueto display target input values beneath each result card.placeholder: sets the placeholder text for the Search Bar widget.debounceMs: sets the delay, in milliseconds, before the widget runs a search after the user stops typing.
The following image shows widget options defined in the HTML page:

-
Confirm network access and CORS Confirm that the application page can reach the Trusted Answer Search ORDS endpoint. If the widget is hosted from a different origin than ORDS, configure Cross-Origin Resource Sharing (CORS) for the ORDS endpoint.
-
Test the widget Load the page, issue a few searches such as
What are the total editors on all Wikimedia pages?, and verify that results are returned from the expected search space. If results do not appear, inspect the browser developer tools for authentication, network, or CORS errors.
Widget REST Endpoints
The widget installer registers the following endpoints under <ORDS_BASE_URL>/trusted-search/search-api/.
identity/
Use the identity/ endpoint to verify that authentication and user identity resolution are configured correctly.
curl -i -H "Authorization: Bearer <ACCESS_TOKEN>" \
"https://<adb-host>/ords/trusted-search/search-api/identity/"
When JWT authentication is configured, a request without a valid bearer token returns 401 Unauthorized.
search/
The widgets use the search/ endpoint to execute searches. The endpoint accepts the query and search space through HTTP headers.
| Header | Description |
|---|---|
X-Q |
User search query text |
X-N |
Search space name |
curl -H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "X-Q: What are the total editors on all Wikimedia pages?" \
-H "X-N: wikimedia" \
"https://<adb-host>/ords/trusted-search/search-api/search/"
The endpoint resolves the user identity, executes the search through DBMS_TRUSTED_SEARCH.SEARCH, and returns the matching results as JSON.
Widget Visuals
Search Bar:

Search Icon:
![]()
When selected, the Search Icon opens a conversational search panel:
![]()
Troubleshooting Widget Integration
- Widget does not load: confirm that the JavaScript file URL is valid and that the file is served over HTTPS when the host page uses HTTPS.
- Search requests fail in the browser: check the browser developer tools for network, authentication, or CORS errors.
401 Unauthorized: confirm that the application sends a valid bearer token and that the token issuer, audience, signing key URL, and scope match the JWT configuration ininstall_widget.conf.remote_identisnullfrom theidentity/endpoint: confirm that JWT authentication is enabled for the endpoint and that the request is using an end-user token rather than a client credentials flow token.SQL*Plus Not Foundduring installation: confirm that SQL*Plus is installed and available in the shell environment where you runinstall_widget.sh.TRUSTED_SEARCH Schema Not Foundduring installation: run the Trusted Answer Search back-end installer before running the widget installer.
API Experience
If you need to run searches from your own back-end service, call the Trusted Answer Search PL/SQL procedure. The application developer is responsible for authenticating and authorizing end-users in their application and ensuring they are permitted to query the target search space.
Connect to the Trusted Answer Search database using your preferred driver (JDBC, python-oracledb, Oracle Call Interface, etc.) and execute the packaged procedure in the DBMS_TRUSTED_SEARCH PL/SQL package:
PROCEDURE search (
p_user_query IN VARCHAR2,
p_search_space IN VARCHAR2,
p_search_space_version_id IN VARCHAR2 DEFAULT NULL,
p_search_record OUT JSON
);
Arguments:
p_user_query– Natural-language query supplied by the end-user.p_search_space– Name of the search space (e.g.,wikimedia).p_search_space_version_id– Optional version ID of the search space. It is recommended to omit this argument so that the default version (i.e., the published version) is queried. However, you can get this ID from the Search Space Versions page in the Admin app to pass another version ID.p_search_record– JSON document returned by the procedure containing search results and relevant metadata.
Exceptions / errors:
-20006– Raised whenp_search_spacecannot be resolved (unknown search space name).-20005– Raised whenp_user_queryexceeds 2,000 characters.-20004– Raised when validation fails (query is NULL or empty, vector-like, no published version exists whenp_search_space_version_idis NULL, or the supplied version ID is invalid/mismatched).-20003– Raised when the caller does not have access to the specified search space.
Example (Wikimedia search space):
DECLARE
l_result JSON;
BEGIN
dbms_trusted_search.search(
p_user_query => 'italian page views',
p_search_space => 'wikimedia',
p_search_record => l_result
);
DBMS_OUTPUT.put_line(l_result.to_string);
END;
/
Sample p_search_record JSON for the query “italian page views”:
{
"version": 1,
"id": "b0f4fd97-8f6f-47a7-9ac1-55b1a2c9d5fd",
"user_query": "italian page views",
"search_matches": [
{
"rank": 1,
"search_target_id": "7a3f8fb3-6b2d-4cf2-95bb-3c8d329cb6a4",
"search_target_title": "Page Views by Country Map",
"match_candidate_type": "SAMPLE_QUERY",
"original_candidate": "Show page views by country for a language",
...
"score": 0.9142,
"url": "https://stats.wikimedia.org/#/it.wikipedia.org/reading/page-views-by-country/normal|map|2-year|~total|monthly",
"target_input_matches": {
"language": "it",
"period": "2-year",
"project": "wikipedia"
}
},
{
"rank": 2,
"search_target_id": "2f4d59b9-7de2-4f63-931c-2aaf61b86f3e",
"search_target_title": "Top Viewed Articles",
"match_candidate_type": "TARGET_DESCRIPTION",
"original_candidate": "This report shows the most viewed articles for a selected Wikimedia project and language.",
...
"score": 0.7575,
"url": "https://stats.wikimedia.org/#/it.wikipedia.org/reading/top-viewed-articles/normal|table|2-year|~total|monthly",
"target_input_matches": {
"frequency": "monthly",
"language": "it",
"period": "2-year",
"project": "wikipedia"
}
},
{
"rank": 3,
"search_target_id": "697de3c7-0b8f-4d55-a963-5e5cde06ed5a",
"search_target_title": "Total Page Views",
"match_candidate_type": "TARGET_DESCRIPTION",
"original_candidate": "This report shows pageview volume for a Wikimedia project over time.",
...
"score": 0.7418,
"url": "https://stats.wikimedia.org/#/it.wikipedia.org/reading/total-page-views/normal|bar|2-year|~total|monthly",
"target_input_matches": {
"frequency": "monthly",
"language": "it",
"period": "2-year",
"project": "wikipedia"
}
}
]
}
Use the returned JSON to render answers, links, or actions from your application.