Active
Project:
Search Files
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Jan 2009 at 09:33 UTC
Updated:
9 Mar 2011 at 15:48 UTC
Jump to comment: Most recent file
Comments
Comment #1
rmiddle commentedcmgui,
It should be doable although I am not sure on the impact that change would have on the server running the search.
Thanks
Robert
Comment #2
cmgui commentedHi Robert
I've been looking at hooks but still cannot find any suitable hook in the search.module file.
It seems that there isn't any Search event which we can write a hook in the search_files.module to hook onto.
Do you have any idea how to do this?
Thank you.
Comment #3
cmgui commentedhi Robert
There is this "Search All" module which seems to do what I want. Unfortunately, it is only for Drupal 5 (and still beta).
http://drupal.org/project/search_all
But the idea is quite good - creating a new search hook "All" which search all the search types: Contents (nodes), Users, Server Files (Search_files), etc.
This may be the direction to work on...
cm gui
Comment #4
rmiddle commentedhook_update_index(). Will feed all the data into the standard search box. But as I said I have no idea how that will effect servers.
Thanks
Robert
Comment #5
haleagar commentedOK so I'm not familiar enough with drupal and the idea of "hook" to know exactly what to do with hook_update_index() as rmiddle mentions.
But I did need this feature, and specifically I want to return a node not a file on the search so I really just want all the attachment text to be included in the node's index.
I'm also not 100% sure how to produce a patch file, though I'm on windows I've got a version of diff and I'll try to figure it out if anyone tells me this is a rational update.
But here is my hack that does the trick.
So using:
In the file:
In the function:
@ line 138 I inserted the following code
The impact on the server is an extra query and insert during indexing, but there should be no impact during a search. This does "taint" the search index with attachment text, (which is what I wanted) if that is not what you want then this may not work for out for you.
Fabulous Module, thanks.
Comment #6
rmiddle commentedhaleagar,
Yea that is what I meant by impact on the server. 1st there is the increase load of inserting the data into the search index. AKA tainting the search index. 2nd this will add all the search data into the index so it will increase storage used by the mysql server and that will increase the time it takes to do any searches. But all the items will be in the main search. To me it makes since to have this as an option but I am not a maintainer of this module so my view means nothing.
Thanks
Robert
Comment #7
cmgui commentedhaleagar & rmiddle
thank you for your replies.
i am beginning to see what you meant.
i'm taking another approach, something along the line of the existing search_all* module. this will not incur additional load on the server as there is not additional indexing.
i've created my own search_all module which has a search hook.
so the search form now has a "All" tab.
And when the user enters a search key, the Drupal core search will automatically go to the new search_all module's _search hook function.
This search_all search function will call all the other modules with search hooks (e.g. node, user and search_files) and do the search.
I am able to reach this stage but am stuck at a very big problem -- paging, i.e. if the search results is more than 10, paging does not work for my module. That is, my search_all module can only work for up to 10 search results.
The problem is : the paging does not work when there are more than one search type being searched, and my module is searching three types: node (Contents), user and search_files (Server Files).
When the results of the 3 search types are combined, the paging disappeared and so only the first 10 results are displayed.
Still trying to fix this.... looks tough... this approach may not be possible at all.....
* there is an existing search_all module but it does not have a drupal 6 version and also does not seem to work for drupal 5.
Comment #8
cmgui commentedIn short, this is the problem:
in my search_all.module file
function search_all_search($op = 'search', $keys = null) {
switch ($op) {
case 'name':
return t('All');
case 'search':
foreach (module_implements('search') as $type) {
if ( $type != "search_all" )
{
$temp1 = module_invoke($type, 'search', 'search', $keys);
if (is_array($temp1) && count($temp1)) {
$results = array_merge( $results, $temp1 );
}
}
}
This does not work. It only shows the first 10 results.
Cannot add the results of node_search with the results of search_files_search, etc., because of paging.
pager_query is the problem here. module_invoke calls node_search, user_search and search_files_search which in turn calls do_search which uses pager_query .... and the results cannot be combined.... logically it is just not possible with the existing core code???
Seems like that there is no way to workaround this.....
Comment #9
idmacdonald commentedI, too, needed to have file attachments come up within the normal content search results. To do this, I took the the search_attachments submodule and changed it into a module called search_attachments_inline. This module indexes file attachments to nodes, and it includes text extracted from the attachment in the search database for the node.
Attached are search_attachments_inline.info, search_attachments_inline.module, and search_attachments_inline.install.
Normally, Drupal includes the snippet of node text with matching terms as part of the search results. I wanted the snippet of attachment text to appear when a search matches text in the attachment. I had to make one nasty hack to Drupal core node.module to make this work. There may be a better way to do this, but I didn't find a suitable hook in node.module to make it work.
In any case, I'm willing to roll this into a proper tar.gz if necessary. Perhaps this could be incorporated into the Search Files project as an additional submodule? Or as a separate project?
Comment #10
idmacdonald commentedOh, and here is a diff of the nasty patch of node.module that I did. The patch is against Drupal 6.10.
-Ian
Comment #11
livingegg commentedsubscribing
Comment #12
egfrith commentedSee #368195: Combining Search Files module with Search module, which is an almost identical issue. I think the code there is probably better, but the idea of a separate module suggested here seems good to me.
Comment #13
punchmonkey commentedSubscribing
Comment #14
broonHey there,
I am starting to face this problem, too, but didn't yet look far into the code. I'd like to first evaluate different approaches. cmgui's solution of creating or porting that search_all.module seems reasonable to me. The paging problem could be overcome by creating a single result page which shows all three (or more if applicable) result sets (content, files, users) in three different columns rather than combining them in one list. This could serve as a first glance at all results (like an extended version of Google's "I feel lucky" button). Instead of displaying the pager below these list there could be a "see more [content|files|users] results" which leads the normal separated search pages.
@cmgui: Is your search_all.module available to download and work on? I think I have to come up with some solution within the next 6 weeks one way or the other to display both content and file results on one page and your approach could be some head start.
Best,
Paul
Comment #15
mstrelan commentedLook at http://drupal.org/node/368195#comment-2834322
Comment #16
babruix commentedThanks for the search_attachments_inline module!
It worked for me to index and show files from CCK filefield,
only i`ve changed query (line 32) to:
And for some reason another way mentioned here http://drupal.org/node/368195#comment-2834322 doesn`t work (for my needs).