Search

Catalyst Search enables data searching in the indexed columns of the tables in the Data Store. It allows you to perform powerful searches through volumes of data with a single search query.

Note: The columns you search for data must be indexed. You can enable search indexing for a column while creating it or by editing it later.

Search Data in Tables

To search for data in a table in a specific pattern, you must specify the table name as the identifier, and add the columns to be searched in. The columns can be added to an array and the array must be passed to the search() method along with the keywords to be searched through an instance of the class ZCatalystSearchOptions.

You must construct the search pattern to pass to the search() method before you execute a search operation, as shown in the code syntax below.

    
copy
ZCatalystApp.getInstance().search( ZCatalystSearchOptions searchOptions, void Function(Map<String, List<Map<String, Dynamic?>>>) onSuccess, void Function(ZCatalystException) onFailed )

Parameters:

  • searchOptions: The instance of the ZCatalystSearchOptions class to be passed to the search() method

You can create the instance for searchOptions in the following way:

    
copy
ZCatalystSearchOptions(searchText: String, ArrayList<ZCatalystSearchOptions.TableColumns) .addSortColumn(tableName: String,columnName: String): Unit .setDisplayColumns(displayTableColumns: ArrayList<ZCatalystSearchOptions.TableColumns>): Unit .setSearchColumns(searchTableColumns: ArrayList<ZCatalystSearchOptions.TableColumns>): Unit .setSearchPattern(pattern: ZCatalystSearchOptions.SearchPattern): Unit

A sample code snippet of a search execution is shown below:

    
copy
List<TableColumn> searchTableColumns = []; //Create an array TableColumn tableColumn = TableColumn('Products'); //Specify the table //Specify the columns to be searched in tableColumn.addColumn('Title'); tableColumn.addColumn('Category'); searchTableColumns.add(tableColumn); //Add the columns in the array ZCatalystSearchOptions searchOptions = ZCatalystSearchOptions('Official', searchTableColumns); //Pass the keyword and the array to be searched ZCatalystApp.getInstance().search(searchOptions, (APIResponse response, Map<String, dynamic> searchResult) { print('Search Query Result :'); print(searchResult); //Actions to be executed with the queried result }, (ZCatalystException exception) { print('Search Query Failed: $exception'); //Actions to be executed upon a failed state });

Last Updated 2023-09-03 01:06:41 +0530 +0530