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
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | faceted_search_sort.module.txt | 2.01 KB | j0rd |
| #31 | faceted_search-defaultsortbyaz-228520.patch | 1.01 KB | chrisns |
Comments
Comment #1
David Lesieur commentedSalut 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).
Comment #2
mvcThanks 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
Comment #3
David Lesieur commentedAdding 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).
Comment #4
mvcHere 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
Comment #5
ThePickwickProject commentedI 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!
Comment #6
David Lesieur commented@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.
Comment #7
ThePickwickProject commentedThanks 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".
Comment #8
David Lesieur commentedAh! 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.
Comment #9
kulvik commentedI'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
Comment #10
mvcI 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.
Comment #11
doc2@drupalfr.org commentedsubscribing
Comment #12
nick_vhWould love to see this in production! Subscribing
Comment #13
nicksanta commented+1 This really is an important feature for an advanced searching module.
Comment #14
miiimoooI'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...
Comment #15
ragethread commentedTo #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.
Comment #16
idmacdonald commentedIt 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
Comment #17
Anonymous (not verified) commentedI would also really need as soon as possible the sorting of terms in the guided search by term weight, not just by count or name! Thank you!
Comment #18
ilw commented+1 subscribing
Comment #19
rodrigoderteano commentedI'm looking for exposed sort options for search results, too (name, date created, most whatever...). It would really make this nice module complete!
I don't know if doing it through views would be the best solution. I tried to get the excerpt display of a keyword search through views 2 and I haven't found a way to do it -> I can't do search highlighting with views! If there's a way to sort results through views exposed filters, then it would be nice to also have a row display of search excerpts in views (is this possible?). Otherwise, I would try to solve this within faceted search. I'm not a drupal expert, but I'd love to see this done, so I'll give this a try...
If I change the ORDER BY part of faceted search's query, would this also alter the order of results displayed by views?
All results in faceted search seem to get sorted by "score", which is a compound of stuff I don't really understand, but that's not the point. Would it be enough to order stuff by something different, like node title (ORDER BY n.title) ?
thanks for your help,
and merry christmas, by the way!
rodrigo
Comment #20
Hobbes-2 commentedsubscribing
Comment #21
wils.solutions commentedSalut mes amis!
We are in the same boat =D Right now I need to sort my results: Alphabetically (title) and 2 taxonomy Date fields.
So, a Sort option on Faceted Search will be really great!
à bientôt!
Comment #22
David Lesieur commentedMarked #442994: how to sort result by node title as a duplicate.
Anyone looking for sort options for search results should look at the above #8 for integrating Faceted Search with Views.
When using a table view, users should be able to choose different sort options if the table's columns are sortable, and if the view does not specify a sort criteria.
Comment #23
wils.solutions commentedSalut David,
SVP, following your advice to use the Views: Could I add 2 links on top of my results (sort by title, sort by post date), then change the Sort order on the fly by the user click option?
tkx
Comment #24
David Lesieur commentedTable views allow that, but if you're not using a Table view, then one way could be to use two separate search environments, each using a view with its own sort criteria. However, you'd need some PHP code to generate those links if you want to preserve the user's current search.
Comment #25
wils.solutions commentedSo, after collecting some info and the David advice to use Views, here you are my solution to Sort Results:
http://www.wilsolutions.com.br/index.php?q=node/4
Thank you!
Wils
Comment #26
dicreat commentedsubscribing
Comment #27
lucascaro commentedsubscribing
Comment #28
j0rd commentedsubscribing
Comment #29
jofdesign commentedUsing Faceted Ajax search forces a node display in views; so if I want to control the way my results display, I need to overwrite search-result.tpl.php . What I did. But now I really need to control the sorting order. I don't know where I can change this.
Does somebody can help me ?
Thank you
Comment #30
chrisns commentedthis helped us, but it is far from solution for everyone (if anyone else at all).
basically this modifies the _add_scoring() from faceted_search class to sort the results by the node title ASC if there are no search params inserted.
i.e. you just go to your /results page of a search
Comment #31
chrisns commentedmissed attachment on previous post
Comment #32
j0rd commentedAlright, I've done this quite elegantly and it can easily be turned into a module with a little effort. I'll provide snippets, but it's up to you guys to do the work in your own module for now. Harass me and I might package this up when I have time.
What you have to do in your faceted_search view:
Create additional page displays on your view for search sort you want. Use the override for this. This will give you a single view with a bunch of different sort options. Then I made a form which displays to the users various sorts. When it's submitted I stick the sort option into a cookie.
When the page loads, I check to see which sort has been chosen and in hook_views_pre_build I modify the "Default" sort array with the ones which relate to my form & the page displays I've created.
This could easily create an admin interface which pulls up the views related to the all faceted search views, then allow the end user to build a select form element with titles based off the additional page views they have in their faceted search view.
Great thing about this is, it's easy to add new sorts....you just use the views interface and add a new entry into your form and form_submit.
Easy breazy.
See attached file, it's all the code you need, but you'll need to adopt it to your needs.