Hi all,

I made a view a while ago with some exposed filters and with 'search terms' filter. The exposed filters are working, but there's a problem with my search terms filter. When i leave the input field open and apply the search, he gives me all records, that's oké. But when i give in a search term, that he must find, he give me no results. It's strange, because with my normal search box, that works. I recently updated my views version, but that didn't help. I'm also getting no errors. He's just giving me no results, equal which search term i give in.

Anyone a solution?

Thanks in advance!
Gunther

Comments

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Can you cut & paste the query the view provides? (You can find this in the live preview information).

guntherdevisch’s picture

Hi,

Below you can find a view that i'm using to test.

$view = new view;
$view->name = 'Gebruikerslijst2';
$view->description = 'Gebruikerslijst';
$view->tag = 'Gebruikerslijst';
$view->view_php = '';
$view->base_table = 'users';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Gebruikerslijst', 'default');
$handler->override_option('fields', array(
  'name' => array(
    'label' => 'Gebruikersnaam',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
  'mail' => array(
    'label' => 'E-mailadres',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
    ),
    'link_to_user' => '0',
    'exclude' => 0,
    'id' => 'mail',
    'table' => 'users',
    'field' => 'mail',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'keys' => array(
    'operator' => 'optional',
    'value' => '',
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => 'keys_op',
      'label' => 'Zoeken: Search Terms',
      'use_operator' => 0,
      'identifier' => 'keys',
      'optional' => 0,
      'remember' => 0,
    ),
    'id' => 'keys',
    'table' => 'search_index',
    'field' => 'keys',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('title', 'Profiel zoeken');
$handler->override_option('header_format', '2');
$handler->override_option('header_empty', 0);
$handler->override_option('items_per_page', 0);
$handler->override_option('use_pager', '0');
$handler->override_option('distinct', 1);
$handler->override_option('style_plugin', 'list');
$handler->override_option('style_options', array(
  'grouping' => '',
  'type' => 'ul',
));
$handler->override_option('row_options', array(
  'inline' => array(
    'picture' => 'picture',
    'name' => 'name',
    'created' => 'created',
    'access' => 'access',
  ),
  'separator' => '',
));
$handler = $view->new_display('page', 'Pagina', 'page_1');
$handler->override_option('filters', array(
  'keys' => array(
    'operator' => 'optional',
    'value' => '',
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'keys_op',
      'identifier' => 'keys',
      'label' => 'Zoeken: Search Terms',
      'optional' => 0,
      'remember' => 0,
    ),
    'id' => 'keys',
    'table' => 'search_index',
    'field' => 'keys',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Use default',
    ),
  ),
));
$handler->override_option('path', 'testzoeken');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => 'Gebruikerslijst',
  'description' => 'Gebruikerslijst',
  'weight' => '2',
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

Thanks for your help,

Gunther

merlinofchaos’s picture

That is the view export. I asked for the query.

guntherdevisch’s picture

Ow sorry merlinofchaos,

Here it is:

SELECT DISTINCT(users.uid) AS uid,
   users.name AS users_name,
   users.mail AS users_mail
 FROM users users

Actually very simple, but when i give in my username in the search field, it doesn't appear.

Any ideas where it goes wrong?

Thanks,
Gunther

merlinofchaos’s picture

Odd, when you apply the search it should show you the new query in the preview. Hm. Not sure what to tell you there.

guntherdevisch’s picture

StatusFileSize
new84.55 KB

Hi merlinofchaos,

Yes, it's very odd! My live preview works, but when i give in a search term on my page, it doesn't give me results. Only when it's not filled in.

In my attach you can find a screenshot of my view. Some words are dutch, but maybe it can help to find the problem.

Thanks for your time,
Gunther

merlinofchaos’s picture

Ok, you're previewing the default display but the default display does not contain the exposed filter, because they are overridden on the page display.

guntherdevisch’s picture

Mm, so you know what's wrong or?

Thanks!

merlinofchaos’s picture

Try previewing the display with the actual search widget...

guntherdevisch’s picture

Sorry, but how can i do that? I'm quite new in Drupal.

Thanks,
Gunther

guntherdevisch’s picture

Hi merlinofchaos,

Here you have another query, when i'm searching for my username. (i didn't know that you could test this too in the live preview)

SELECT DISTINCT(users.uid) AS uid,
   SUM(search_index.score * search_total.count) AS score,
   users.name AS users_name,
   users.mail AS users_mail
 FROM users users 
 LEFT JOIN search_index search_index ON users.uid = search_index.sid
 LEFT JOIN search_total search_total ON search_index.word = search_total.word
 WHERE (search_index.word = 'guntherdevisch') AND (search_index.type = 'users')
 GROUP BY search_index.sid, uid, users_name, users_mail
 HAVING COUNT(*) >= 1

Maybe there is something wrong with this query, because i'm getting no results.

Thanks!
Gunther

guntherdevisch’s picture

Can somebody help me? Merlinofchaos? Or someone else?

Thanks!
Gunther

arvinsingla’s picture

StatusFileSize
new16.56 KB

I'm having a similar problem on a view of users with an exposed search filter. No results are being generated when I search for any terms.

Here is the query before a search:
SELECT users.uid AS uid, users.name AS users_name, users.mail AS users_mail, users.login AS users_login FROM users users ORDER BY users_login DESC

Here is a query when I put in a search term:
SELECT users.uid AS uid, SUM(search_index.score * search_total.count) AS score, users.name AS users_name, users.mail AS users_mail, users.login AS users_login FROM users users LEFT JOIN search_index search_index ON users.uid = search_index.sid LEFT JOIN search_total search_total ON search_index.word = search_total.word WHERE (search_index.word = 'shamelin') AND (search_index.type = 'users') GROUP BY search_index.sid, users_login, uid, users_name, users_mail HAVING COUNT(*) >= 1 ORDER BY users_login DESC

I have also attached an image of the view. Let me know if you would like me to export my view as well. Any light you could shed on this would be great. Thanks!

guntherdevisch’s picture

Version: 6.x-2.5 » 6.x-2.6
Status: Postponed (maintainer needs more info) » Needs review

Hi,

I just installed the 6.x-2.6 version of views, but i'm still having the problem with my exposed search filter:(

@tkamen: Do you have the problem only when you expose the search filter on a list of users or?

Any help is welcome.

Thanks,
Gunther

mcrittenden’s picture

Title: No search result with views » No search results with exposed "search terms" filter
Status: Needs review » Active
CONFUSEDNOOB’s picture

i have same issue i can display mutliple fields for search they appear in block with drop downs all is perfect except the search will not show anything. very odd i think drupal needs a better search i am using 6.4

bonobo’s picture

Status: Active » Postponed (maintainer needs more info)

Given that this issue is about an exposed search filter, and that the search filters work very well, this can likely be traced to a couple things:

1. As merlinofchaos points out in #7 you need to preview the correct display.
2. Has cron run? If the search index has not been built, then the search will not return any results.

guntherdevisch’s picture

StatusFileSize
new278.29 KB

Hi,

Thanks for your feedback.

I have tested my view in the live preview on my page display, but i'm getting no results.

Here's my query:

SELECT DISTINCT(users.uid) AS uid,
   SUM(search_index.score * search_total.count) AS score,
   users.mail AS users_mail,
   users.name AS users_name
 FROM users users 
 LEFT JOIN search_index search_index ON users.uid = search_index.sid
 LEFT JOIN search_total search_total ON search_index.word = search_total.word
 WHERE (search_index.word = 'test') AND (search_index.type = 'users')
 GROUP BY search_index.sid, uid, users_mail, users_name
 HAVING COUNT(*) >= 1

Here, i'm searching on a username, called 'test'. I also tried other usernames/usermails, but no results are given. Only when i leave the search-box empty, i'm getting all the results.

In the attachment, you can find a screenshot of my page display (note: my view is in dutch, hope you can understand).

I also tried updating my cron manually, but that didn't did the trick.

Thanks for the help.

Greets,
Gunther

derby’s picture

I am having the same problem with Exposed Search Filter on Views2.

After I run cron my search index table doesn't contain type = 'users'.

search_index.type = 'users'. This is false. Therefore no results are returned.

Why does the search indexing bypass the users?

simmoe’s picture

I have the same problem, really can't figure it out. Drupals own search form query for users doen't seem to use indexing at all: " SELECT name, uid, mail FROM users WHERE LOWER(name) LIKE LOWER('%test%') OR LOWER(mail) LIKE LOWER('%test%')
"

Simon

guntherdevisch’s picture

Status: Postponed (maintainer needs more info) » Needs work

Doesn't anyone have a solution for this problem?

I think there's enough info here now, if not please say so.

Thanks,
Gunther

simmoe’s picture

Alternately does anyone know how to alter the query made by views on the search?

Best, Simon

mcrittenden’s picture

Status: Needs work » Active
guntherdevisch’s picture

Hi,

I ran the query below in PhpMyAdmin, but i'm getting also no results. So i looked in the table search_index, but there i didn't found a search_index.word = 'test' or search_index.type = 'users'. I just found 'help' and 'node' as search_index types. Does somebody know why there are no 'users' types indexed?

SELECT DISTINCT(users.uid) AS uid,
   SUM(search_index.score * search_total.count) AS score,
   users.name AS users_name,
   users.mail AS users_mail
 FROM users users 
 LEFT JOIN search_index search_index ON users.uid = search_index.sid
 LEFT JOIN search_total search_total ON search_index.word = search_total.word
 WHERE (search_index.word = 'test') AND (search_index.type = 'users')
 GROUP BY search_index.sid, uid, users_name, users_mail
 HAVING COUNT(*) >= 1

Thanks,
Gunther

guntherdevisch’s picture

Hi,

When i manually add the user to the search_index table, my (views) search works:)
Now i just have to automate this proces. Making sur that whenever a useraccount is created or adjust, the search_index is updated.

Anyone ideas where i can do that? In which script/module?

I'll keep you updated, when i have more news.

Thanks,
Gunther

guntherdevisch’s picture

Hi guys,

I made it work! I tried the 'reindex'-module & 'profile-search'-module and then run my cron. I think the profile-search module did the trick!
So all who has the same problem as me, i suggest you try the modules i mentioned here above.

Greets,
Gunther

simmoe’s picture

Hmm - strangely it still dosn't work for me though. I installed both reindex and profile-search (which seems to be called profile-plus, yea?) and ran cron - but still nothing happpens when i search users with views. Did i miss something maybe?

Best, Simon

simmoe’s picture

Maybe your trick was to manually add the 'user' to the search_index table? In that case it's still a bug, i guess. Or maybe some contrib module caused it in the first place - as far as i can interpret from the above the developers checking it out did not experience the problem?

guntherdevisch’s picture

Hi Simon,

The second module i used, wasn't 'profile plus', but 'profile search', here's the link: http://drupal.org/project/profilesearch, run your cron afterwards.

Hopely it works now,

Greets,
Gunther

dawehner’s picture

simmoe’s picture

Hey Gunther and Dereine -

I installed profile_search and now it works! Thanks alot.

There is still the small problem that you have to type entire words from i.e. the username or profile fields. Specifically i am making a phonebook search and it would be reasonable to show results even if the user only types the beginning of a name - so 'sim' would still return my user (simon). I guess this is a performance issue but the standard drupal usersearch returns results from 3 letters up - just like normal content searches. Maybe this should be posted elsewhere?

Anyway: thanks - this helps a lot

best,
Simon

ari-meetai’s picture

Status: Active » Closed (fixed)

@simmoe try the Finder module: http://drupal.org/project/finder

Basically what you got is that the index has to be updated with the new profile fields, hence the problem gets solved with profile_search. ~|~

Moniroaf’s picture

I made a view with some exposed filters and with 'search terms' filter. The exposed filters are working, but there's a problem with my search terms filter.
He's just giving me no results, equal which search term i give in.
am using it in D8
any solution ?
thanks