If data source is sorted by some field before indexing
and use docID instead of search score for sorting:
we'll get search result sorted by some field


modify IndexSearcher's HitCollector:
...about line 112
scorer.score(new HitCollector() {
        private float minScore = 0.0f;
        public final void collect(int doc, float score) {
          if (score > 0.0f &&                     // ignore zeroed buckets
              (bits==null || bits.get(doc))) {    // skip docs
not in bits
            totalHits[0]++;
            if (score >= minScore) {
              /* lucene calculate score for sorting docs 
               * hq.put(new ScoreDoc(doc, score));        //
update hit queue
               * so if we use docID or 1/docID instead of
score for sorting
               * we'll get search result sort by docID or by
docID desc
               * if data was sorted by some field before
indexing
               * we'll get search result sort by some
field...
               */
              hq.put(new ScoreDoc(doc, (float) doc));     //
<==use doc instead of score for sorting
              if (hq.size() > nDocs) {            // if hit queue
overfull
                hq.pop();                         // remove lowest in hit queue
                minScore = ((ScoreDoc)hq.top()).score; // reset
minScore
              }
            }
          }
        }
      }, reader.maxDoc());

_________________________________________________________
Do You Yahoo!? 
���ʵ���,���ֵ��� - �Ż��Ƴ�������ֵ����ܱ�!
http://cn.ent.yahoo.com/newsletter/index.html

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to