Remove dependence on search.module

DamienMcKenna - June 23, 2009 - 03:39
Project:Apache Solr Search Integration
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Solr provides a complete replacement for the built-in search engine, so why retain a dependency on the core search.module? Right now, if I'm reading this correctly, if you want to only use the Solr search engine and not waste the database & system with unwanted search.module calls you have to run a basically hack core to remove certain lines out of search.module (using CoreSearch.module)? Obviously, this is a bad situation, advocating hacking core is not a good thing. Why not just duplicate the functionality that's needed out of search.module and drop it completely, leaving a much cleaner system?

#1

JacobSingh - June 23, 2009 - 03:44
Status:active» duplicate

http://drupal.org/node/405206

#2

DamienMcKenna - June 23, 2009 - 06:01

Thanks. I searched but didn't include "fixed" in the criteria so didn't find this one. Glad to see it.

#3

robertDouglass - July 16, 2009 - 11:58
Version:6.x-1.x-dev» 6.x-2.x-dev
Status:duplicate» active

We need to go ahead with the original intent of this issue and completely decouple our module from core search. Core search enforces way too many assumptions and limitations. For example, we call search_data() for no good reason... all it does is invoke our apachesolr_search_search hook. Then, we use the standard theming for core search results. This breaks if you want to display more or less than 10 results per page because the THEME layer assumes 10 items (core search has this assumption hardcoded in many places):

<?php
function template_preprocess_search_results(&$variables) {
 
$variables['search_results'] = '';
  foreach (
$variables['results'] as $result) {
   
$variables['search_results'] .= theme('search_result', $result, $variables['type']);
  }
 
$variables['pager'] = theme('pager', NULL, 10, 0);  // <---- eat that, sucka!
  // Provide alternate search results template.
 
$variables['template_files'][] = 'search-results-'. $variables['type'];
}
?>

So I'm reopening the issue with the original title and original intent.

#4

robertDouglass - August 13, 2009 - 13:49
Status:active» needs review

Here's step one. Instead of calling search_data, call apachesolr_search_search directly. Eventually I'd like to refactor apachesolr_search_search to be individual functions and not related to search module's API.

AttachmentSize
kill_search_data.patch 868 bytes

#5

moshe weitzman - August 22, 2009 - 15:35

subscribe. still a big fan of this direction.

#6

robertDouglass - September 17, 2009 - 13:25

And another baby step. Don't depend on search.module to call cron for us.

AttachmentSize
hook_cron.patch 857 bytes

#7

robertDouglass - September 17, 2009 - 13:27

Committing these two patches. More to come.

#8

robertDouglass - September 17, 2009 - 14:06

Ok. These are truly baby steps. That last patch broke things so I have to pull in some of the code from search_data to compensate. One layer of extrication at a time :(

AttachmentSize
not_so_fast_mr.patch 979 bytes

#9

DamienMcKenna - November 4, 2009 - 00:03

How about a patch that clears the core search_* tables on cron?

#10

robertDouglass - November 4, 2009 - 10:26

Damien, what would such clearing accomplish? Just "truncate search_index" and so forth? And, why would we need to do that every cron run?

Controlling core search behavior isn't really the purview of the ApacheSolr module, imo.

 
 

Drupal is a registered trademark of Dries Buytaert.