global class AccountLookupSearchHandler extends B25.SearchHandler {
global override B25.SearchResultCollection getSearchResults(B25.SearchContext searchContext) {
B25.SearchResultCollection collection = new B25.SearchResultCollection();
for (Account account : [SELECT Id, Name, (SELECT Name FROM Contacts LIMIT 2) FROM Account LIMIT 20]) {
List<String> metaTextArray = new List<String>();
for (Contact contact : account.Contacts) {
metaTextArray.add(contact.Name);
}
collection.addSearchResult(new B25.SearchResult(account.Id, account.Name).setMetaText(String.join(metaTextArray, ', ')));
}
return collection;
}
} |