No empty result with exposed Search: Index filter

plach - September 12, 2007 - 17:06
Project:Views
Version:5.x-1.6
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:by design
Description

Hi, I'm marking this as a bug report but I'm not sure if the behaviour I found is by design: I was playing with an experimental view exposing a Search: Index filter and I couldn't get an empty result set even if I entered text absolutely not existing in my test nodes (for example _unfindable_): any unfindable text led to a list of the whole set of test nodes.

I gave a look to modules/views_search.inc and found that inserting the following line in the code fixed the problem

<?php
--- views/modules/views_search.inc    Sat Mar 03 23:59:33 2007
+++ views/modules/views_search.inc    Wed Sep 12 19:03:26 2007
@@ -39,7 +39,8 @@

      
// Calculate maximum relevance, to normalize it
      
$normalize = db_result(db_query('SELECT MAX(relevance) FROM temp_search_sids'));
-      if (!
$normalize) {
+      if (!
$normalize) {
+         
$query->add_where("0");
         return;
       }
      
$select2 = str_replace('i.relevance', '('. (1.0 / $normalize) .' * i.relevance)', $select2);
?>

Could you give me a feedback?

AttachmentSize
view_export.php_.txt2.57 KB

#1

plach - October 27, 2007 - 10:58
Status:patch (code needs review)» by design

cdo

#2

Zoologico - August 6, 2008 - 17:33

I got around this using:

http://drupal.org/project/views_fastsearch

Instead of the default Search Index.

 
 

Drupal is a registered trademark of Dries Buytaert.