Search Data

Catalyst Search enables you to search and retrieve data records from the Catalyst Data Store. You can execute a search query using the executeSearchQuery() method for searching for a particular pattern of data. The search reference used in the code snippet is the component instance.

Create a JSON Configuration

The following code snippet creates a JSON object that contains the attributes of the pattern to be searched for, in the indexed columns of the individual tables.

Copied//Create a config object with the search term, table and indexed columns
    let config = {
        search: 'santh*',
        search_table_columns: {
            SampleTable: ['SearchIndexedColumn'],
            Users: ['SearchTest']
        }
    };

Execute Search Query

The JSON object created in the previous section is passed as a parameter to the executeSearchQuery() method which returns a promise. The promise returned will be resolved to an object which is a JSON.

Copied//Execute the search query by passing the configuration
let search = app.search();  
let searchPromise = search.executeSearchQuery(config);
searchPromise.then(searchResult => {
        console.log(searchResult);
});

A sample response that you will receive is shown below. The response is the same for both versions of Node.js.

Node.js

Copied{
  AlienCity: [
    {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-13 13:49:19:475",
      CityName: "Dallas",
      CREATEDTIME: "2021-08-13 13:49:19:475",
      ROWID: "2136000000008508"
    }
  ]
}