sorting search results

mvc - February 29, 2008 - 19:36
Project:Faceted Search
Version:5.x-0.11
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

Salut encore, David.

This is probably a stupid question but I can't figure out how to display the sort options block. I've enabled the block in admin/build/block, but I don't see it anywhere, with or without views integration. Further, I don't see this block anywhere on the demo site. I feel like I'm missing something really obvious but I can't tell what.

Tracing through the code on my test site, I only see faceted_search_ui_block() called with the 'list' op in the uistage 'results', but I see that faceted_search_ui_show_sort_options() does nothing except in 'facet'. So, I'm confused. Does this block only appear under certain preconditions?

I'm not able to work around this using a table view with sortable columns, because I would like to be able to sort by taxonomy terms, and this is not an option for a table page view.

Thanks,
Matt

#1

David Lesieur - March 1, 2008 - 18:10

Salut Matt,

It is probably not so obvious, but this block is only for sorting facet categories, not search results. If you click the "more" link in a facet (in the Guided search), you'll get to a full page with that facet's categories, and if the Sort options block is enabled it appears on that page.

To sort search results, you could set fields as Sortable in Views, but that will work only if the sort option of Faceted Search's argument is not used (it would override any other sort criteria). But well, yes, not all taxonomy fields are sortable in Views (the Taxonomy: Term field is sortable, but not Taxonomy: Term for Vocabulary).

#2

mvc - March 3, 2008 - 16:21

Thanks for the explanation.

I am using multiple "Taxonomy: Term for Vocabulary" fields, and I see from the Views issue queue that sorting those fields in the Views module would be difficult and is probably not going to happen.

I am apparently out of options. So, how feasible would it be to add the ability to sort faceted search results? If you are interested and have time, my company would consider sponsoring this feature for your module. If so, please give us an idea of how much this would cost.

Thanks,
Matt

#3

David Lesieur - March 10, 2008 - 15:43

Adding this feature to Faceted Search could end up being a significant task, and would also duplicate some of what Views already does. So I'd say we have to do it with Views. I have an idea on how do implement it, but I'm not sure a patch would have any chance to be accepted in Views because it would require additional table JOINs. If these JOINs can be performed only when absolutely needed, then perhaps the patch would be acceptable.

I could not find the Views issues on this subject, but these might give some useful info (if you can post the links).

#4

mvc - March 10, 2008 - 16:50
Title:How to display Sort options block?» sorting search results
Category:support request» feature request

Here are some posts in which merlinofchaos explains how views uses drupal core's table sorting api to expose sort options to the user:

http://drupal.org/node/150896
http://drupal.org/node/158859

#5

pawshaker - April 6, 2008 - 20:18

I have a question which probably relates to this. For a classifieds type of site, we're using faceted search. It would be very nice to have the latest listings appear at the top of the search results. Or is this integrated with the core drupal search settings, where you can give a heigher weight to "recency"? By the way, thanks for this nice module!

#6

David Lesieur - April 6, 2008 - 23:25

@pawshaker: You may put more weight on the "Recently posted" factor in Administer > Site configuration > Search settings, and reduce the weight of other factors. Faceted Search takes these core settings into account.

#7

pawshaker - April 7, 2008 - 14:28

Thanks David, this seems to work a little bit better. However, it doesn't seem possible to fully obtain the straightforward "order in descending order of creation time".

#8

David Lesieur - April 7, 2008 - 20:04

Ah! Then you may display the results with a View that's sorted that way. See the README.txt file provided with Faceted Search for instructions on how to use a View for search results.

#9

kulvik - October 29, 2008 - 20:47

I'm currently setting up a product search (based on übercart and faceted search). It's all working perfectly for me except for sorting the search results. I can set the sort order by using a view (which i'm currently doing), but I really need a way to let the users choose the sort criteria they want. Since exposed filters aren't supported (and table view with sorting enabled on column titles don't work) i'm out of ideas here..

The optimal solution would be to have a select list (drop-down) where customers can choose different search criteria (price asc/desc, date published asc/desc etc.).

Have anyone done anything like this before with faceted search? How much work would it require? And do anyone have any tips on where / how to start implementing this?

Best regards,
Thomas Kulvik

Ny Media AS
www.nymedia.no
+47 4000 7955

#10

mvc - November 5, 2008 - 16:27

I don't know how to do this, although I suspect that what you describe will be easier in Views 2. Just for the record, we ended up working around this by manually setting the date created field of each node so that search results would appear as we wanted them. But that won't help you, since you want to let users change the order.

#11

doc2@drupalfr.org - February 5, 2009 - 09:42

subscribing

#12

Nick_vh - February 5, 2009 - 16:20

Would love to see this in production! Subscribing

#13

nickurbits - April 7, 2009 - 04:02

+1 This really is an important feature for an advanced searching module.

#14

miiimooo - April 16, 2009 - 12:48

I've tried changing the Content Ranking sectors in core search but using a taxonomy facet I see no difference. I have three results in results/date_authored:2009 taxonomy:157 but the order doesn't change when I change the Recently posted weight to 0, 5, or 10.
I'm trying to show the most recent first...

#15

ragethread - November 6, 2009 - 02:09

To #14:
I had the same problem. Faceted Search sorts seach results by the latest of created, changed or last comment.

if you want the results to be sorted by node creation time replace:

faceted_search.inc line 1307:

$score_field[] = '%d * POW(2, (GREATEST(MAX(n.created), MAX(n.changed), MAX(c.last_comment_timestamp)) - %d) * 6.43e-8)';

with

$score_field[] = '%d * POW(2, (MAX(n.created) - %d) * 6.43e-8)';

Also make sure that in the search settings ( /admin/settings/search ) "Recently posted" has the greatest weight.

On the same topic, Faceted Search should have its own result sorting options, without the need of Views.

#16

idmacdonald - November 26, 2009 - 13:15

It would be great if the Faceted Search could used the weights set in the Search Ranking module. I'm using faceted search 6.x-1.x-dev. I've had a look at the code, but patching faceted search to use those ranking looks like a non-trivial task.

-Ian

 
 

Drupal is a registered trademark of Dries Buytaert.