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;
                }



_______________________________________________
sword-devel mailing list: sword-devel@crosswire.org
http://www.crosswire.org/mailman/listinfo/sword-devel
Instructions to unsubscribe/change your settings at above page

Reply via email to