2

I would like to enable the basic intuitive functionality to search by first and last name in all search tools.

Currently on our new install, with no other plugins enabled, I get "no matches found" if I search for firstname space lastname.

Here is what I'm finding when I do these searches for a contact that does exist and does have a case associated with him.

Search for joe, good results
Search for johnston, good results
Search for joe johnston, "no matches found"
Search for Joe Johnston, "no matches found"
Search for johnston joe, good results
Search for Johnston Joe, good results

I've found the same results using all of the below search locations which makes sense.
search > find contact
advanced search
cases > find cases
cases > open a case

The quick search does display my contact as an option when I enter "joe".

I would greatly appreciate any suggestions to get this working. It's a basic functionality that I assume can be enabled??

I also tested this on the demo site for Lou Adams and got the same results. It seems to be the default functionality.

Thanks so much for your help.

2 Answers 2

3

First check that you have Automatic Wildcards enabled, navigate to Administer -> Customize Data and Screens -> Search Preferences, is the first option.

If enabled, wildcards are automatically added to the beginning AND end of the search term when users search for contacts by Name. EXAMPLE: Searching for 'ada' will return any contact whose name includes those letters - e.g. 'Adams, Janet', 'Nadal, Jorge', etc. If disabled, a wildcard is added to the end of the search term only. EXAMPLE: Searching for 'ada' will return any contact whose last name begins with those letters - e.g. 'Adams, Janet' but NOT 'Nadal, Jorge'. Disabling this feature will speed up search significantly for larger databases, but users must manually enter wildcards ('%' or '_') to the beginning of the search term if they want to find all records which contain those letters. EXAMPLE: '%ada' will return 'Nadal, Jorge'.

Check your display and sort name, navigate to Administer->Customize Data and Screens->Display Preferences at the bottom you have two fields, which by default should look something like this:

Individual Display name format: {contact.last_name}{, }{contact.first_name}

Individual sort name format: {contact.last_name}{, }{contact.first_name}

If you want to search always by first name you can change the sort name format to {contact.first_name}{ }{contact.last_name}, now this will only apply for new contacts and not for the existing ones, you will have to update the sort_name for the existing contacts, there was a discussion in the forum about this.

If you search for "Adams," in the demo site you'll see that the result will be "Adams, Lou", as far as I'm concerned, this is expected behaviour.

Edit

Forgot to mention that you can use wildcards like: %joe%, that should include Joe Johnston and Johnston Joe if there is a existing contact by that name.

10
  • Thank you Andrei. That is very helpful. Is there a way to set up the search so it would find it if you searched by Mike Smith or Smith Mike?
    – 406CODE
    Commented Apr 14, 2016 at 21:38
  • I don't think is currently possible without using wildcards, see the last addition in the answer, perhaps some of the core team could shed some light on that.
    – Andrei
    Commented Apr 14, 2016 at 21:43
  • I do have wildcards enabled. I'm sorry, I forgot to mention that.
    – 406CODE
    Commented Apr 14, 2016 at 21:51
  • What is the sort name format set to?
    – Andrei
    Commented Apr 14, 2016 at 21:56
  • {contact.first_name}{ }{contact.last_name}
    – 406CODE
    Commented Apr 14, 2016 at 22:09
2

I know this is very old, but here's a solution for future reference:

I've developed an extension that allows to search for sort_name OR display_name which would solve this issue in most configurations.

https://civicrm.org/extensions/search-display-name

It's not extensively tested, so if you do run into issues let me know on github.


There is another extension that allows for the same result although differently:

https://github.com/artfulrobot/alternativenamesearch

It patches the core to split the search terms and search for them individually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.