<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
L.J.Arthur Neil wrote:
<blockquote cite="mid005501c606e1$15890f70$3c01a8c0@Neils" type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta content="MSHTML 6.00.2600.0" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">
<pre><font size="3">Hi All,</font></pre>
<pre><font size="3">How can I do soring.I am able to Index and order .But the Sort function doesn't work.</font></pre>
</font></div>
</blockquote>
This question may be best answered by the lucene users mailing list.<br>
<br>
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?<br>
<br>
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.<br>
<br>
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.<br>
<br>
In His Service,<br>
DM Smith<br>
<blockquote cite="mid005501c606e1$15890f70$3c01a8c0@Neils" type="cite">
<div><font face="Arial" size="2">
<pre><font size="3">I have used the following code;</font></pre>
<pre><font size="3"> Query* q = QueryParser::parse(tline,_T("contents"),&analyzer);</font></pre>
<pre><font size="3"> //buf = q->toString(_T("contents"));
// _tprintf(_T("Searching for: %s\n\n"), buf);
//_CLDELETE_CARRAY(buf);</font></pre>
<pre><font size="3"> //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;
}
</font></pre>
</font></div>
</blockquote>
</body>
</html>