Problem/Motivation

Realname module cannot alter the user search query.

Proposed resolution

Add a query tag to core and extend the query by realname data.

Remaining tasks

User interface changes

None

API changes

None.

#2116391: Tag user_search_execute() query for realname and other modules

Original report by @bulldozer2003

When I do a user search, results are matched by the user ID and not the real name.

ex. I have two users "Tom Smith" and "Sally Smith" their user IDs are "tsmith" and "ssmith" respectively.
If I do a user search for "Tom" or "sally" I will get no results.
If I search for "smith" I will get both "Tom Smith" and "Sally Smith" as results.
If I search for "tsmith" I will get "Tom Smith" as a result.

Comments

C. Lee’s picture

Same here

bulldozer2003’s picture

Category: support » bug
C. Lee’s picture

Category: bug » support

I heard that hidden fields are not indexed and now I'm only hiding the realname field by CSS. And still no luck.

C. Lee’s picture

Category: support » bug

sorry

modreoci’s picture

The same problem... It works in 6.x why not in 7.x?

mbosma’s picture

Any update on this? I'm still not getting real names to show up in search results.

almc’s picture

The same issue seems to be in the current recommended release 7.x-1.1 of the module, installed with D7.23. Search is not done by user's real name and not configurable to do so. At the same time the ability to find a person by real name is very important if the real name functionality is decided as needed for a web site.

hass’s picture

Status: Active » Closed (duplicate)
almc’s picture

I've applied the patch realname_1722112+Autocomplete+for+entityreference+fields.patch from that thread and re-indexed the search but it doesn't seem to have helped with this issue. The search in User category is still done by a user name, not by real name.

hass’s picture

Status: Closed (duplicate) » Active

Oh, i thought it means autocomplete fields... Reopening

I guess the realname is missing in the search index.

hass’s picture

Ok, this is what need to be done to solve this issue here.

  1. In core the query in https://api.drupal.org/api/drupal/modules%21user%21user.module/function/... need to add a query tag e.g 'user_search'. What may block us here is we need to get this into D8 first and than backported. Not sure how long this may take.
  2. we need to alter the query with hook_query_alter() and join the realname table.
  3. we must stop deleting the realname on user update as we need it all times or the search will fail. This is also required for views in a different case. So just a follow up task
almc’s picture

Thank you for the detailed insight, I may need to elaborate on the code although it would take much longer for me, would be great if the update for version 7 could come earlier, not diminishing importance of version 8 though, would be staying tuned ...

hass’s picture

Help reviewing this core minor addition and set it to RTBC and it goes in... :-)))

almc’s picture

ok, would be happy to help as much as I can ...

almc’s picture

Issue summary: View changes

a

hass’s picture

hass’s picture

hass’s picture

Issue summary: View changes
hass’s picture

Issue summary: View changes