Search
Search Data in Indexed Columns
Search executes a searchQuery() method to search for a particular pattern of data. You can search:
- Data in multiple tables
- Only data in search indexed columns
To learn more about search please refer to the documentation here.
The following code snippet contains the pattern to search for in specified columns of the tables:
Ensure the following packages are imported:
Copiedimport com.zc.component.object.ZCRowObject;
import com.zc.component.search.ZCSearch;
import com.zc.component.search.ZCSearchDetails;Copied//Get an instance of SearchDetails
ZCSearchDetails search = ZCSearchDetails.getInstance();
//Set the pattern to be searched
search.setSearch("Sa*");
//Create a hashmap for the tables and corresponding column lists to search
HashMap<String,List<String>> map = new HashMap<String,List<String>>();
List<String> searchList1 = new ArrayList<String>();
List<String> searchList2 = new ArrayList<String>();
//Add indexed columns of same or different tables to the list
searchList1.add("SearchIndexedColumn");
searchList2.add("SearchTest");
//Add the table with its name and the column lists
map.put("SampleTable", searchList1);
map.put("Users", searchList2);
//Set the table-column mapping for searching
search.setSearchTableColumns(map);
//Execute Search by passing the search instance with the details
ArrayList<ZCRowObject> rowList = ZCSearch.getInstance().executeSearchQuery(search);