Well, there will always be a perf hotspot somewhere, I think the question is 
whether that code gets you to your desired query rate or not.  I'll sit and 
wait to see what others say.


Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch



----- Original Message ----
> From: Jonathan Ariel <[EMAIL PROTECTED]>
> To: solr-user@lucene.apache.org
> Sent: Monday, October 20, 2008 11:39:33 AM
> Subject: Re: Getting a document by primary key
> 
> Thanks Otis, but since I'm working on my own RequestHandler I need the
> actual code that I should execute on the SolrIndexSearcher or IndexReader to
> get the document.
> Right now I'm doing the following:
> 
>     public Document getDocumentByUniqueKey(String id,
>             SolrIndexSearcher searcher, IndexSchema schema) throws
> IOException
>     {
>         SchemaField uniqueKey = schema.getUniqueKeyField();
>         if (uniqueKey != null)
>         {
>             Term t = new Term(uniqueKey.getName(), uniqueKey.getType()
>                     .toInternal(id.toString()));
>             int docID = searcher.getFirstMatch(t);
>             if (docID >= 0)
>             {
>                 return searcher.doc(docID);
>             }
>         }
>         return null;
>     }
> 
> But this doesn't seems to be good enough. Profiling with netbeans I see the
> following line as a HotSpot:
> int docID = searcher.getFirstMatch(t);
> 
> 
> 
> On Mon, Oct 20, 2008 at 1:16 PM, Otis Gospodnetic <
> [EMAIL PROTECTED]> wrote:
> 
> > Jonathan, http://...../.....?q=:should
> > be fine.
> >
> >
> > Otis
> > --
> > Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch
> >
> >
> >
> > ----- Original Message ----
> > > From: Jonathan Ariel 
> > > To: solr-user@lucene.apache.org
> > > Sent: Monday, October 20, 2008 11:09:35 AM
> > > Subject: Getting a document by primary key
> > >
> > > I'm developing my own request handler and given a document primary key I
> > > would like to get it from the index.
> > > Which is the best and fastest way to do this? I will execute this request
> > > handler several times and this should work really fast.
> > > Sorry if it's a basic question.
> > >
> > > Thanks!
> > >
> > > Jonathan
> >
> >

Reply via email to