Search Data

Search executes a searchQuery() method for searching for a particular pattern of data. The search used in the code snippet is the component instance.

Create a Search Configuration(JSON)

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.

    
copy
//Create the Query Object to be used for searching //The Search key contains the patterns to be searched //The search_table_columns is a JSON object which contains the table name as key and an array of the columns to be searched as the value. var QUERY = { "search": "santh*", "search_table_columns": { "customerDetails" : ["indexC1"], "SampleTable" : ["indexC2"] } };

Execute Search

The JSON object created in the previous section is passed as a parameter to the searchQuery() method which returns a promise.

Note : The promise returned will be resolved to an object in which the content key contains the search results with the key as the table name and its value as the array of rows.
    
copy
//search the table by passing the query object which in turn returns a promise var search = catalyst.search; var searchPromise = search.searchQuery(QUERY); searchPromise .then((response) => { console.log(response.content); }) .catch((err) => { console.log(err); });

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

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

Last Updated 2023-11-14 13:20:49 +0530 +0530