Re: [Katta-developer] retrieving lucene document details best possible approach in Katta
Brought to you by:
joa23
From: Xiaomeng W. <sha...@gm...> - 2010-08-30 22:12:38
|
I use this to retrieve a field containing int values. Integer.parseInt(client.getDetails(hit,field).values().toArray()[0].toString()); It should be better since it doesnot fetch again. Regards, Xiaomeng On Sat, Aug 28, 2010 at 11:31 AM, arindam ghosh <ari...@gm...> wrote: > > > > > Hi All, > I was working with Katta and I had to retrieve the document details, to > display the actual field value and the content of the lucene document. > I have basically done it by adding the below metioned code in search > method(highlighted in bold below) and have retrieved the same successfully. > I have added other necessary code in LuceneClient for communicatig to the > server.(Not adding it here) > But since it is basically fetched after I get the hits from the search it is > taking a longer time. > Just wanted to know that wether it is the best possible approach while using > Katta. > Thanks in advance. > > void search(final String[] indexNames, final String queryString, final int > count) throws Exception { > > final ILuceneClient client = new LuceneClient(); > > final Query query = new QueryParser(Version.LUCENE_CURRENT, "", new > KeywordAnalyzer()).parse(queryString); > > final long start = System.currentTimeMillis(); > > final Hits hits = client.search(query, indexNames, count); > > final long end = System.currentTimeMillis(); > > System. > > out.println(hits.size() + " hits found in " + ((end - start) / 1000.0) + > "sec."); > > int index = 0; > > final Table table = new Table(new String[] { "Hit", "Node", "Shard", > "DocId", "Score" }); > > for (final Hit hit : hits.getHits()) { > > table.addRow(index, hit.getNode(), hit.getShard(), hit.getDocId(), > hit.getScore()); > > index++; > > String[] shardname = {hit.getShard()}; > > // added for retrieving document details > > String[] filedName = { > > "content","contentId"}; > // added for retrieving document details > > client.retriveDocumentDetails(indexNames, > shardname,hit.getDocId(),filedName); > > } > > System. > > out.println(table.toString()); > > } > > Regards, > > Arindam > > > > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Katta-developer mailing list > Kat...@li... > https://lists.sourceforge.net/lists/listinfo/katta-developer > > |