Hi All, Thanks for your reply. I would like to mention here is that the companyId is a multivalued field. I tried paul's suggestions also but doesn't seem much gain. Still the searcher.doc() method is taking almost the same amount of time.
> you can use the FieldCache to lookup the compnayId for each doc. on the > aggregate this will most likely be much faster then accessing the stored > fields. > As i understand the FieldCache, it will load fields for all the documents. But in our case we want to load fields only for the matched documents. Here is the code snippet after using the BitSet: *public Map getIds() { MapFieldSelector selector = new MapFieldSelector(new String[] {COMPANY_ID, ID}); for(int i=bitSet.nextSetBit(0); i>=0; i= bitSet.nextSetBit(i+1)) { try { doc = searcher.doc(i, selector); mappedCompanies = doc.getValues(COMPANY_ID); } catch (CorruptIndexException e) { } catch (IOException e) { } } return results; } * Any suggestions for further optimizing the code. Thanks and Regards, Vipin