Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-11 Thread Paul J. Lucas
On Jun 11, 2009, at 1:49 AM, Ian Lea wrote: This thread seems to be veering well away from your original straightforward question on how to convert your straighforward code. So what? It's about Lucene and hence on-topic. Why do you care? If you want or need these advanced solutions, fine,

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-11 Thread Ian Lea
This thread seems to be veering well away from your original straightforward question on how to convert your straighforward code. If you want or need these advanced solutions, fine, but if your existing code was fast enough the modified versions suggested earlier are probably fast enough too. -- I

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Paul J. Lucas
On Jun 10, 2009, at 5:02 PM, Yonik Seeley wrote: On Wed, Jun 10, 2009 at 7:58 PM, Daniel Noll wrote: It's a shame we don't have an inverted kind of HitCollector where we can say "give me the next hit", so that we can get the best of both worlds (like what StAX gives us in the XML world.) You

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Yonik Seeley
On Wed, Jun 10, 2009 at 7:58 PM, Daniel Noll wrote: > It's a shame we don't have an inverted kind of HitCollector where we > can say "give me the next hit", so that we can get the best of both > worlds (like what StAX gives us in the XML world.) You can get a scorer and call next() yourself. -Yo

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Daniel Noll
On Wed, Jun 10, 2009 at 20:17, Uwe Schindler wrote: > You are right, you can, but if you just want to retrieve all hits, this is > ineffective. A HitCollector is the correct way to do this (especially > because the order of hits is mostly not interesting when retrieving all > hits). Hits and TopDoc

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Paul J. Lucas
On Jun 10, 2009, at 10:49 AM, Uwe Schindler wrote: To optimize, store the filename not as stored field, but as a non- tokenized, indexed term. How do you do that? - Paul - To unsubscribe, e-mail: java-user-unsubscr...@lucen

RE: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Uwe Schindler
hetaphi.de > -Original Message- > From: Paul J. Lucas [mailto:p...@lucasmail.org] > Sent: Wednesday, June 10, 2009 5:26 PM > To: java-user@lucene.apache.org > Subject: Re: Migrating from Hit/Hits to TopDocs/TopDocCollector > > On Jun 10, 2009, at 3:17 AM, Uwe Schindler wrote: >

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Paul J. Lucas
On Jun 10, 2009, at 3:17 AM, Uwe Schindler wrote: A HitCollector is the correct way to do this (especially because the order of hits is mostly not interesting when retrieving all hits). OK, here's what I came up with: Term t = /* ... */ Collection files = new LinkedList(); FieldS

RE: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Uwe Schindler
ll be >>10 times as fast! > > > > - > > Uwe Schindler > > H.-H.-Meier-Allee 63, D-28213 Bremen > > http://www.thetaphi.de > > eMail: u...@thetaphi.de > > > >> -----Original Message- > >> From: Wouter Heijke [mailto:whei...@xs4al

RE: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Wouter Heijke
sage- >> From: Wouter Heijke [mailto:whei...@xs4all.nl] >> Sent: Wednesday, June 10, 2009 11:44 AM >> To: java-user@lucene.apache.org >> Subject: Re: Migrating from Hit/Hits to TopDocs/TopDocCollector >> >> >> Will this do? >> >> IndexReader

RE: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Uwe Schindler
e 10, 2009 11:44 AM > To: java-user@lucene.apache.org > Subject: Re: Migrating from Hit/Hits to TopDocs/TopDocCollector > > > Will this do? > > IndexReader indexReader = searcher.getIndexReader(); > TopDocs topDocs = searcher.search(Query query, int n); > for (int i =

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Wouter Heijke
Will this do? IndexReader indexReader = searcher.getIndexReader(); TopDocs topDocs = searcher.search(Query query, int n); for (int i = 0; i < topDocs.scoreDocs.length; i++) { Document document = indexReader.document( topDocs.scoreDocs[i].doc); final File f = new File( document.get( "FILE" ) )

Re: Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-10 Thread Ian Lea
Hi The code below might do the job. Based on the example at http://lucene.apache.org/java/2_4_1/api/core/org/apache/lucene/search/Hits.html Completely uncompiled and untested of course. TopDocCollector collector = new TopDocCollector(hitsPerPage); final Term t = /* ... */; Query query = new Te

Migrating from Hit/Hits to TopDocs/TopDocCollector

2009-06-09 Thread Paul J. Lucas
I have existing code that's like: final Term t = /* ... */; final Iterator i = searcher.search( new TermQuery( t ) ).iterator(); while ( i.hasNext() ) { final Hit hit = (Hit)i.next(); // "FILE" is the field that recorded the original file indexed