The proposal is to change it to regex but the comments suggest the primary reason for this is that it makes more sense to search from the start of the string. This being the case it seems that we could opt to use an indexed query rather than regex
foreach ($mappings as $key => $dbName) {
if (!empty($searchParams[$key])) {
- $queryParams[$nextParamKey] = array('%' . $searchParams[$key] . '%', 'String');
+ // CRM-18694.
+ $wildcard = strstr($key, 'postcode') ? '' : '%';
+ $queryParams[$nextParamKey] = array($wildcard . $searchParams[$key] . '%', 'String');
$where[] = $dbName . " LIKE %{$nextParamKey} ";
$nextParamKey++;
}