[CLucene-dev] Re: [sword-devel] clucene-sorting

Ben van Klinken bvanklinken at gmail.com
Fri Dec 23 05:46:59 MST 2005

As of clucene 0.9 you can also write a custom sorter, which could
directly compare the verses, thus saving index size - at the cost of a
slower first search (subsequent searches can have their sort cached).


On 12/23/05, DM Smith <dmsmith555 at yahoo.com> wrote:
>  L.J.Arthur Neil wrote:
>  Hi All,
>  How can I do soring.I am able to Index and order .But the Sort function
> doesn't work.
>  This question may be best answered by the lucene users mailing list.
>  What are you attempting to do? It is not clear from your example what you
> are sorting upon. The Sword modules do not have a "modified" field. What is
> left uncommented is the return of documents in index order, which should be
> the same as verse order when searching a Bible. Is this not working?
>  In order to sort, Lucene requires that the field is represented a certain
> way in the index. If you let us know which field you are going after, we can
> check to see if that field is constructed sufficient for sorting.
>  One way to sort is to do it externally to lucene. For example, with each
> verse in the index is a stored verse reference. This can be converted to a
> number representing its ordering in the Bible. Setting a bit in a bit map
> and then iterating over the bits in the bit map will give the verses in
> Bible order.
>  In His Service,
>      DM Smith
>  I have used the following code;
>   Query* q =
> QueryParser::parse(tline,_T("contents"),&analyzer);
>                  //buf = q->toString(_T("contents"));
>         //      _tprintf(_T("Searching for: %s\n\n"), buf);
>                 //_CLDELETE_CARRAY(buf);
>                  //searcher->setSort(_T("modified"));
>                 //SortField *sort_Field = new SortField(_T("modified"));
>                 //SortField *sort_Fields = new SortField(*sort_Field);
>                 //Sort *sort = new Sort(sort_Field);
>                 //sort->setSort( new SortField (_T("modified"),
> SortField::STRING, true) );
>                 //sort->setSort( _T("modified"),true);
>                 //sort->setSort( _T("modified") );  */
>                 Hits* h;
>                 try
>                 {
>                 h = searcher->search(q, sort::INDEXORDER);
>                 //h = searcher->search(q);
>                 }
>                 catch(...)
>                 {
>                         //printf("err\n");
>                         printf("Unrecoverable error occured!!!Please do
> search again...\n");
>                         //printf(err.what());
>                 //fflush(stdout);
>                         return;
>                 }
>  -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
> for problems? Stop! Download the new AJAX search engine that makes searching
> your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
> _______________________________________________
> CLucene-developers mailing list
> CLucene-developers at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/clucene-developers

More information about the sword-devel mailing list