The search module purpots to be a general and re-usable framework, but fundamentally fails at this for a few reasons, including that there is no way to disable core node and user search, no way to choose a path for searches other than the module name, no way to choose something other than node as the default, that search module itself contains implementaitons of hook_nodeapi, hook_comment, etc, which imply that it knows certain details of the data it's indexing, etc.
The general approach to come out of discussions with catch, webchick, RobertDouglas, and others is to have some sort of info hook liek hook_node_info which allows a single module to define one or more searches, define the base name used for callbacks, etc.
Some of the existing and somewhat related issues:
#343834: Avoid module_exists for search module in node module
#503982: Enable search module by default
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | less-suck-505214-11.patch | 30.97 KB | pwolanin |
| #9 | less-suck-505214-9.patch | 34.92 KB | pwolanin |
| #5 | less-suck-505214-5.patch | 34.23 KB | pwolanin |
Comments
Comment #1
catchOK so the main thing which needs fleshing out I think is that fact that node module implements search module hooks, and search module implements node module hooks, and people don't seem happy with either of those at various times.
The answer I've seen (and I think a contrib module by Robert Douglass already implements this), is refactoring the core search implementations into node_search.module and node_user.module - I'm not overly keen on that because it adds a lot of cruft to the modules page, for something which only really matters at an API level.
While I didn't give it lots of thought yet, was thinking more along the lines of a hook_search_info() hook.
so node_search_info() {
return array(
'type' => 'node',
array (
'search path' => content,
'indexer' => 'node_search_index',
)
}
Then you'd be able to swap out bits and pieces of this with a hook_search_info_alter(). So for example I think user_search() currently does direct queries rather than building an index, but with fields in core, it's possible someone would want to build a search index for users using all the rendered information from fields. The other option is doing it OO style, or we might need a combination of both - but something like this at least allows us not to require an extra module for every search implementation - I think it'd be good to be able to search for taxonomy terms in core for example (at least in taxonomy administration), and adding a taxonomy_search.module starts to look really messy.
Comment #2
eaton commentedI'd give a big thumbs up to that. It would make swapping out alternate implementations much easier, and also make it easier to determine what modules are providing search pages on the site.
Comment #3
damien tournoud commentedThere are three elements in play:
There are two hooks to define: one between the search UI and the data provider (let's call that
hook_search_object_info()), and one between the search index provider and the data provider (let's call thathook_search_index_<index>()).The problem of the current hook_search() is that it tries to do both at the same time:
hook_search_object_info()hook_update_index()belong intohook_search_index_<index>()EDIT: refined the repartition above.
Comment #4
damien tournoud commentedMy current vision is that we need two modules:
hook_search_object_info()hook_search_index_coreThe node module will implement
hook_search_object_info()like this:search_index will provide the core indexer, and will also provide implementations of
hook_search_index_corefor base core objects (node, user, but probably also taxonomy vocabulary and terms). A search implementation is very tightly coupled between the object provider and the index provider (take a peak at http://api.drupal.org/api/function/node_search/7 and get convinced... most of node_search() is useless for say... Apache Solr), so it would make little sense to move that into the node module directly.Comment #5
pwolanin commentedThis is a really pretty simple patch that mostly moves code around.
It kills $op, add a separate access hook, and lets modules specify the path instead of forcing the module name.
From the search admin page you can disable any of the search implementations.
Doesn't yet have nice module names - and still need to think about letting the info hook define an include file and also moving all the misc hooks from search module to node module ... or a new module? most of this code shoudl really be in neither node module nor search module.
Comment #6
Anonymous (not verified) commentedPatch read pretty good and it seems to work properly for me.
Comment #7
JacobSingh commentedToo busy to give enough of a review to put RTBC, but otherwise would:
1. This is obviously a much better architecture format, and disabling user search without disabling the user module, is a good thing.
2. This patch shouldn't change much because it is basically just splitting up a massive hook, easy to commit IMO if it works correctly.
As Peter mentioned on IM:
needs a little cleanup to get nice module names - there's a sucky APi
So I think a little language / format work on the new settings page and this is ready to go.
Comment #8
janusman commented@Joshua had already marked it RTBC; just switching the status back.
Comment #9
pwolanin commentedOk, final cleanup - just get the real module names.
Comment #10
pwolanin commentedneeds re-roll for #394182: DBTNG search.module
Comment #11
sun.core commentedComment #12
pwolanin commentedre-roll just applying dbtng changes. back to RTBC if it passes testbot.
Comment #13
dries commentedCommitted to CVS HEAD. Thanks.