Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Sorting Search Results

Quote Reply
Sorting Search Results
I'm having trouble getting the search results to sort purely by date added with the newest links on top. In Links.pm I've set the sort to:
$LINKS{build_sort_order_search} = "Add_Date DESC";
and set the weight to 1 on the title only, however, the results are not coming out chronologically.
Any ideas would be much appreciated.
Thanks.
Quote Reply
Re: Sorting Search Results In reply to
Do you have a lot of "alt" links defined??

Quote Reply
Re: Sorting Search Results In reply to
Firstly, hope I don't sound too ignorant, but what are "alt" links?
Secondly, I've run into another snag which I have to solve.
I'm importing links from Links 2 through a browser using Import.cgi.
I almost got there. I dropped existing tables, then created tables, and, as I have added an extra field, I redifined the Links.def, SQL.mysql, set all fields to not required and all links imported OK, however, the Date did not import and all links we're set to the current date. So I used Add_Date in the db header but the script tells me it's in an invalid format. I haven't changed the Links 2 date format, mmmm, so I can't test the search results until I get this solved. Any ideas here?
Thanks.
Quote Reply
Re: Sorting Search Results In reply to
The "alt"links are when you place a link in one category, but also add it to other categories. What happens is the links search, and the alt-links search are munged, and it's not done properly.

As for the date.... You are using the most current version of the import.pl?

What you need to do is add the field to the links table. You then need to re-sync the DEF files! Make sure the field is in the .def file for the Links table.

The Import.pl file I believe reads the .def file, then assumes that your links.db is in the SAME ORDER as the fields in the .def file.

If your fields are not in the same order, that could explain it.

What you need to do is drop the Links table, and using the SQL.mysql as a guide, put the fields that are in the links.db in the same order at the top of the list, with any new fields, or extra fields coming AFTER the fields in your links.db.

Then, create the Links table using the snippet of code from the SQL.mysql file. You can just paste the Create Table.... code into the SQL monitor. Make sure you resync the .def file!

When you run the Import.pl routine, it will take the fields, and assign them to the Links table, in order, then fill in the extra fields as it sees fit.

If your links.db is:

field1
field2
field3
field4
field5

your Links table can't be:

field1
field2
field6
field3
field4
field5

but it_can_ be:

field1
field2
field3
field4
field5
field6
field7
field8 ....

give that a try!

It's been awhile since I've had to use the import.pl program.






Quote Reply
Re: Sorting Search Results In reply to
So I have everything up and running well now, thank you kindly, the only stumbling block left is the search function. I would like link results to appear in Add_Date DESC order. In the Links.pm I've set:

$LINKS{build_sort_order_search} = "Add_Date DESC";

The weight is set to 1 in the Links Table Title field only. There are no "alt" links. The only major mod I've made to the Links Table is set the Add_Date to DATETIME type. I've searched the entire forum for any similar problems but zilch. I've tried setting the sort order to "ID DESC" which would amount to the same thing in my case but no luck, even tried "isNew" but no change.
Has anyone had any similar problems or ideas on what to try?

Thanks.
Quote Reply
Re: Sorting Search Results In reply to
Thanks for the speedy reply. Could you explain the exact way for me to do this. In Search.pm I tried changing all instances of SELECT FROM to ORDER BY but it as just a shot in the dark, far off the mark I fear.
I should try eating more carrots eh?
Quote Reply
Re: Sorting Search Results In reply to
No, it's a deep problem.

There is a second 'search/sort' thread going on here, and some answers can be found there.

Alex is never around on the weekends it seems, but I've asked if he has any update on when new code is coming out and what fixes we can expect.

Otherwise, I'll see if I can't come up with a fix for the search.cgi problem, and preserve the select by score, but rank by whatever parameter the users want. The "score" is very valuable as far as relevancy.... but it's less than useful if you are trying to format the output.

Quote Reply
Re: Sorting Search Results In reply to
The problem is the "search" function returns value in 'score' order.

When it searches, it ranks the links by "score" and that's how it returns them.

To get around that, you'd have to change the search query to a "select from" statement, and use the "order by" parameter to set the order.

This has been a problem, and hopefully Alex has addressed it in the next relase of the program.



Quote Reply
Re: Sorting Search Results In reply to
The downside of search-ni.cgi is that by being non-indexed, it's a lot slower and more resource intensive.

I guess if you left the main searches going to search.cgi, but when it wrote out the templates, the clickable column names could link to search-ni.cgi.

That way if someone wanted to sort them, they could, otherwise you'd still be using the indexed search.

Quote Reply
Re: Sorting Search Results In reply to
For a short term fix, you can use search-ni.cgi instead of search.cgi. It will be easy to make sort by anything.

Cheers,

Alex