Closed (duplicate)
Project:
Search Files
Version:
6.x-2.0-beta4
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Oct 2009 at 16:19 UTC
Updated:
18 Aug 2010 at 23:20 UTC
Hello,
I installed the search files module and currently you can either search nodes with the standard Drupal search, or click on the "search in directories" tab and search for PDFs. I would like to merge the two into a single search and get a query result with both relevant nodes and relevant pdfs, a little bit like what the Google search does on websites. You might get a page for the first result and a PDF for the second element in the result list because of its relevancy.
Is there a way to do this with search files? Or is it something that would require development.
Thanks so much for your help and insights,
Comments
Comment #1
captaindav commentedI have the same question, how to merge the file hits with content hits into one list sorted by relevancy.
Comment #2
yraber commentedsubscribe
Comment #3
webservant316 commentedsubscribe
Comment #4
broonAs pointed out in http://drupal.org/node/368195#comment-2072572 you have to alter core's search module right now:
Best,
Paul
Comment #5
curtaindog commentedThe code in #4 will not work for any search that returns more than one page of results.
Comment #6
broon@curtaindog: I'm not really experienced with the drupal search yet, so I'd like to know why this won't work. Or in your opinion shouldn't work as it does at http://www.clearingstelle-eeg.de where I implemented this code change (site is in German, try to search for the term "biomasse" which is one of the top terms. The search result page shows several pages with different content types as well as pdf documents.)
Comment #7
curtaindog commented@sin.star - First, I apologise that my comment was not more constructive, I just wanted to warn people that this is not an easy problem. In the thread you refer to, this comment and this comment suggest that there are problems with the result merge approach. Personally, I tried something similar and wound up getting duplicate elements in my search results. That being said I did run your search and it appeared to work (though I don't know any German and even less about biomass so I'm not the most reliable witness :)
From my understanding the results are paginated before they are returned from the module_invoke call, so you get the effect of (page n of set x + page n of set y) rather than (page n of set x + set y). This in itself is probably not a big deal although it would cause some result pages to be longer than others. More importantly though is that Drupal's pager widget pulls its data from the most recent search so if the most recent search had only one match you'd only get a link to one page, regardless of the number of matches for the other search(es).
Note that this is just what I've inferred from comments around the place, I haven't dived too deeply into the code, and I hope to be proven wrong.
CurtainDog
Comment #8
curtaindog commentedOk, here is a new hacked up version. Note that as each module is doing its own query we can't rely on the database for paging and thus we have to pull 'all' matches out, merge and repage them in the code. Ack! So to stop your site grinding to a halt I would limit the search to something like 100 matches per module and tell users to enter more search terms if the result they're looking for isn't returned.
So the first thing to do is to go into the do_search function and up the pager query to something more solid like 100 or 1000. We're paging in code so this number represents all the results we're going to get out of a particular module for a particular query, so it's got to be big enough to be useful but not so big that the search eats all your memory.
Actually, I like the results that come out of this better than the natural search files query as for my particular case there's always a lot of vanished files, which results in pages looking uneven. By paging at the end each page is nice and even.
Comment #9
jschrab commentedIs there any plans to fold this sort of thing into D7?
Comment #10
benone commentedmy question is - does it finally work with filefield from cck ?
and also - is it already merged with standard search so i can use it in my views search term exposed filter ?
no one use today standard search.
and no one use upload module to have file attached to node.
there is filefield and views exposed filters now and it could be great to have it working with them.
thanks.