Thank  you Hoss. I was exactly looking for sth like
TopFieldCollector.create(...). Basically my objective is to sort the
document by the document number(I have read only index with only one
segment & also because of some other requirements). Here's what I did,

// create a sort field based on document number
SortField sortField = new SortField(null, Type.DOC);
// create a sort instance based on the sortField
Sort sort = new Sort(sortField);
// create a fieldDoc instance from the 'ScoreDoc after' instance
FieldDoc fieldDoc = new FieldDoc(after.doc, 0, new Object[] { after.doc });
// create a collector, this collector will be wrapped later on(but i am not
showing that part here)
TopFieldCollector collector = TopFieldCollector.create(sort, numHits, fieldDoc,
true, false, false, true);
// search the index
indexSearcher.search(query, collector)

Logically, everything should be working fine. But I get
"java.lang.ArrayIndexOutOfBoundsException:
-1" all the time. The only part that looks problematic is the instance of
FieldDoc. Since I have defined the sort to be based on Document Number in
lucene, my fieldDoc must have the document number of the "after" ScoreDoc
as per the documentation. But this is somehow not working. I would
appreciate your suggestions.

Best,

--
Kailash Budhathoki




On Sat, Jun 7, 2014 at 12:00 AM, Chris Hostetter <hossman_luc...@fucit.org>
wrote:

>
> : I was wondering why there is no search method in lucene Indexsearcher to
> : search after last reference by passing collector. Say a method with
> : signature like searchAfter(Query query, ScoreDoc after, Collector
> results).
>
> searchAfter only makes sense if there is a Sort involved -- either
> explicitly or implicitly on "score"
>
> When you use a Collector, even if your collector produces "ScoreDoc"
> objects, a subsequent (hypothetical)
> call searchAfter(Query,ScoreDoc,Collector) would have no idea what the
> meaning of "after" was for that ScoreDoc.
>
> (Even if the ScoreDoc was an instance of FieldDoc that encapsulated the
> values for the sort fields, it doesn't know what the fieldNames are, or
> what the comparator/direction to use against those field+values are to
> know what is "after" them).
>
> So from an API standpoint: it just doesn't make any sense.
>
> if you want searchAfter functionality along with custom Collector logic,
> take a look at things like TopFieldCollector.create(...) which you could
> then wrap in your own Collector.
>
>
> -Hoss
> http://www.lucidworks.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>

Reply via email to