Re: [greenstone-users] Sorting in reverse order

From Katherine Don
DateFri, 31 Oct 2003 17:50:14 +1300
Subject Re: [greenstone-users] Sorting in reverse order
In-Reply-To (sfa0f609-088-GwDom1-wlu-edu)
Hi John

When you do an 'all' or boolean search, the search engine does not do ranking and returns document ids in the order that it received them during indexing. So if your documents were processed in alphabetical order of Title during building, then that is the order they should be returned from a boolean search. If you do a 'some' or ranked search, then they will be returned in ranked order.

However, looking at the code, it appears that greenstone is still trying to sort the results even if a boolean search is carried out. (I think) it is trying to sort  based on document rank, which  will all be 0. Then, due to the way the list is handled during a sort, it actually gets mixed up, and becomes semisorted, backwards.

If you have a close look at the list of documents in your search results, you will see that they are not actually sorted - there are two blocks of Z-As.

A fix for this is not to  sort if the search was not ranked.

You can edit the mgqueryfilter.cpp file in src/colservr:

around line 344, there is a call to sort_doc_results(request,;

change this to:

    if (num_phrases > 0 || (request.filterResultOptions & FRranking)) {
      sort_doc_results (request,;

You will need to recompile greenstone. (run make and make install in the gsdl directory).
Once you have done this, your search results will be in the order of processing during building, which will be alphabetically by Title (-sortmeta Title ).

The sorting during import uses perl cmp string comparison function. If this doesn't give you the order  you want you can modify the perl stuff to use your own function.
The perl module where the actual sorting is done is perllib/, in the functions get_OID_list and get_file_list.

If you need help with any of this, please feel free to ask.

hope this helps,
Katherine Don

John Doyle wrote:

I'm new to Greenstone.  Have just put up a collection of about 30,000
small html files that point to where the full-text of journals can be
found.  I have a problem, which you can see at:
The alphabetical arrangement in the query result is in reverse
alphabetical arrangement.  My import statement was: -removeold -verbosity 0 -sortmeta Title fulltxt
Any way of getting an A-Z arrangement?  And even better, a case
insensitive A-Z sort?
John Doyle

greenstone-users mailing list