I wanted to clarify if I am doing something wrong or there is a malfunction:

When search terms exposed filter is searched with 1 word, it gives results. When searched with 2 keywords, it does not.

Is there any way to correct this ? I didn't see any place for configuration. I assume it should give results normally as using the same data as search module, which works in this case as expected.

I am using the default taxonomy_term view that comes with View 2 module, which has 2 arguments and 2 sorting criteria, in case any of these are causing malfunction ??? Can this be confirmed ?

Thanks

Files: 
CommentFileSizeAuthor
#19 373760-fix-aggregate.patch2.2 KBmerlinofchaos

Comments

cincy_kid’s picture

I am having a similar problem.

In my views, when using filters, if its a one word term like "casual" it works fine but anytime its more than word, like "business casual" not only does it not work but it gives me 2 SQL errors pointing to:

/modules/views/includes/view.inc on line 697

and

/modules/views/includes/view.inc on line 723

which both look like they have to do with the results (maybe with the count or pager i dunno).

I have 3 different views that all work the exact way (fine with 1 word terms and these 2 SQL errors on 2+ words)

Do you also get a SQL error on yours sbydrupal?

sbydrupal’s picture

Cincy, in my case, there is no sql error, however, it does not show any results with multiple words.
I have seen some other posts with similar results where views search term filter misses some searches where the core drupal search picks up.

cincy_kid’s picture

weird..ok, I still think it will help solve my problem when we figure out why 2+ words are not working in views exposed filters

wOOge’s picture

I'm having the same issue.
As an example I'm able to bring up results using "apple" or "pie", but not "apple pie". I don't get any SQL erros in the drupal log-watch though.

I re-indexed my site completely, including removing and uninstalling (deleting the search index tables) and re-enabling the Search module, but no luck.

Drupal 6.9
Views 6.x-2.3

David_Rothstein’s picture

Status:Active» Postponed (maintainer needs more info)

I tried to reproduce this problem and couldn't -- the Views Search worked correctly for me regardless of whether I tried a single or multiple word search...

Maybe someone who is experiencing this could attach an export of a view for which the problem occurs?

DamienMcKenna’s picture

Here's a sample query produced by Live Preview when I am querying for two different terms:

SELECT node.nid AS nid, node.title AS node_title, node.created AS node_created FROM node node  LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data ON term_node.tid = term_data.tid WHERE (term_data.vid in ('1')) AND (term_node.tid IN (1, 2, 3, 4, 5, 6, 42)) AND (term_data.name = 'caribbean atlantic') ORDER BY node_created DESC

FYI, the term_nide.tid list are parent terms, 'caribbean atlantic' is a child term of tid=1.

DamienMcKenna’s picture

This is the same problem as #301159: using two taxonomies for filtering.

wOOge’s picture

Here is my Views2 Export:

$view = new view;
$view->name = 'xsearch';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$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', 'Keyword Search', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => 'Title',
    '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_node' => 1,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
  'created' => array(
    'label' => 'Post date',
    '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,
    ),
    'date_format' => 'medium',
    'custom_date_format' => '',
    'exclude' => 0,
    'id' => 'created',
    'table' => 'node',
    'field' => 'created',
    'override' => array(
      'button' => 'Override',
    ),
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'keys' => array(
    'operator' => 'required',
    'value' => '',
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 1,
      'operator' => 'keys_op',
      'identifier' => 'keys',
      'label' => 'Search: Search Terms',
      'optional' => 1,
      'remember' => 0,
    ),
    'id' => 'keys',
    'table' => 'search_index',
    'field' => 'keys',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('items_per_page', 50);
$handler->override_option('use_pager', '1');
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'desc',
  'columns' => array(
    'title' => 'title',
    'created' => 'created',
  ),
  'info' => array(
    'title' => array(
      'sortable' => 1,
      'separator' => '',
    ),
    'created' => array(
      'sortable' => 1,
      'separator' => '',
    ),
  ),
  'default' => 'created',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'xsearch');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));

And here is the query it produces:

SELECT node.nid AS nid,
   SUM(search_index.score * search_total.count) AS score,
   node.title AS node_title,
   node.created AS node_created
FROM node node
LEFT JOIN search_index search_index ON node.nid = search_index.sid
LEFT JOIN search_total search_total ON search_index.word = search_total.word
WHERE (search_index.word = 'apple' OR search_index.word = 'pie') AND (search_index.type = 'node')
GROUP BY search_index.sid, node_created, nid, score, node_title
HAVING COUNT(*) >= 2
ORDER BY node_created DESC
merlinofchaos’s picture

For those that are having this problem, what version of MySQL (or pgsql) are you using?

DamienMcKenna’s picture

MySQL v5.0.51a

DamienMcKenna’s picture

Clarification: issue 301159 is related but not necessarily the same.

cincy_kid’s picture

MYSQL DB 5.0.67

Also to clarify, the problem occurs when its 2 words inside the same filter box, not just because I am using multiple filters.

So, if I have 2 filters (color and weight) consider these 2 examples:

1) If I select "Blue" in the first exposed filter and "Heavy" in the second exposed filter it returns results just fine.

2) If I select "Light Brown" in the first exposed filter and "Heavy" in the second exposed filter I get no results plus the SQL error I posted above because Light Brown has a space in between it and is 2 words instead of one.

wOOge’s picture

I'm using MySQL v5.1.30

brooho’s picture

I upgraded mysql to 5.0.77 but problem still remains
and I think I understand
my view ( http://drupal.org/node/373390 ) produced query:

SELECT node.nid AS nid, SUM( search_index.score * search_total.count ) AS score, node.vid AS node_vid, node.type AS node_type, node.title AS node_title
FROM node node
LEFT JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN term_data term_data ON term_node.tid = term_data.tid
LEFT JOIN search_index search_index ON node.nid = search_index.sid
LEFT JOIN search_total search_total ON search_index.word = search_total.word
WHERE (
term_data.vid
IN (
'1'
)
)
AND (
search_index.word = 'philips'
OR search_index.word = '444'
)
AND (
search_index.type = 'node'
)
GROUP BY search_index.sid, nid, score, node_vid, node_type, node_title
HAVING COUNT( * ) >=2

but score is different for 'philips' and for '444' and it is not groupped

AND it is hard to reproduce becouse sometime it work correctly (when score equals)

wOOge’s picture

If I remove HAVING COUNT(*) >= 2 from my original MySQL Query below, it works - I get the right results at the top of the list, but it spews out all nodes after that.

SELECT node.nid AS nid,
   SUM(search_index.score * search_total.count) AS score,
   node.title AS node_title,
   node.created AS node_created
FROM node node
LEFT JOIN search_index search_index ON node.nid = search_index.sid
LEFT JOIN search_total search_total ON search_index.word = search_total.word
WHERE (search_index.word = 'apple' OR search_index.word = 'pie') AND (search_index.type = 'node')
GROUP BY search_index.sid, node_created, nid, score, node_title
HAVING COUNT(*) >= 2
ORDER BY node_created DESC
merlinofchaos’s picture

Status:Postponed (maintainer needs more info)» Active

Ah! Blast it I see, that score is a calculation and should NOT be part of the group by. That makes a lot of sense. Thank you for the clarification. I still don't know why this behavior changed.

wOOge’s picture

Thanks for looking into this for us!!

brooho’s picture

Yes, thank you, merlinofchaos :)

merlinofchaos’s picture

Status:Active» Needs review
StatusFileSize
new2.2 KB

Please tell me if this patch fixes the problem for you.

dww’s picture

Issue tags:+drupal.org upgrade

Now that the issue adv search pages are views, this is potentially nailing us on d.o, too. I'll try to test this in a little while, dealing with a lot of things right now....

mshaver’s picture

Patch worked for me!

merlinofchaos’s picture

Status:Needs review» Closed (duplicate)
Issue tags:-drupal.org upgrade

http://drupal.org/node/362830 points out other things broken with search, and fixing them led to a bit of a renovation. Even though this is not technically a dup, I'm marking it such because the patch there includes this patch and they are not separable.

wOOge’s picture

Yup this patch worked for me too!
Thanks!!

brooho’s picture

Yes, it works!

sjf’s picture

Version:6.x-2.3» 6.x-3.x-dev
Status:Closed (duplicate)» Active

I'm still having this problem with Views 6.x-3.x-dev. e.g. I have several nodes with the same taxonomy term "light brown". I have a Views page with a single search filter.

  • If I type "light" or "brown" into the search box all results are returned
  • If I type "light brown" no results are returned

It does seem to be a bit random. For example, I might have two nodes with the term "light green" and if I search "light green" I might get one result back. Searching "light" or "green" would return both. I can't figure out the pattern.

I've tried this on two sites on two different servers and I have the same problem so I think the issue is still here. I only have details of one server to hand - PHP 5.2.9 and MySQL 5.0.81

Views 6.x-2.6 and 6.x-2.x-dev work perfectly. I'm setting this issue back to active as I don't know if updating the patch mentioned in #22 is still the fix.

FreddieK’s picture

I'm experiencing the same or a similar problem. When filtering for event nodes I can use taxonomy terms such as 'theatre' or 'dancing' separately, but written as 'theatre dancing' results in no nodes found. If I instead write them as 'theatre, dancing' results for both of the terms are found (which is the desired result), but why does the comma have to be there? For new users of a site search function it's kinda' counter-intuitive.

dawehner’s picture

Status:Active» Closed (duplicate)

Please create new issues for new problems related to 3.x