Search API
The Search API provides a way to search MongoDB databases, as long as your data is properly exposed to the Itential Platform search engine. This guide explains how to set indexes and expose your data collections using search objects.
Only use this guide to modify custom applications. Do not modify or update Itential applications.
Expose an application for searching
A database collection can be searched if it is exposed with a search object. This search object is added to the pronghorn.json file and consists of an object, or array of objects, following the schema below.
Search object attributes
Examples
Empty search template
Search exposure object
Currently, only text-based fields ("type": "string") are supported for searching.
Create an index for exposed collections
You must create the appropriate indexes for your fields to be search-enabled. MongoDB uses compound indexes — list each field name followed by 1 as the value.
The compound index must match the fields in the search template. For example, if you want to search on name and type, you must have a compound index on both fields.
To create an index against a local instance for testing, run the following in a MongoDB collection browser. This example creates an index on the MOP templates collection for name:
Follow these guidelines when creating indexes:
- Avoid creating too many indexes. Excess indexes slow down inserts into the database.
- Always set
backgroundtotruewhen creating indexes to support performance at scale. - Test the addition of search objects in a lab environment to monitor performance before releasing to production.
Make a search request
The POST body consists of a data object with a text property containing the value to search for.
Empty request
Search object example (searching for the word workflow):
Search results
Results follow the map object configured above, with the addition of _id and tags fields:
Top-level result fields
Result group fields
Individual search result fields
Currently supported Itential applications
The following Itential applications already have search objects and indexes configured:
Additional information
The Search REST API is currently used only by the site-wide search box in the top navigation bar. You can, however, use the results in your own application if needed.