lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Bamford <>
Subject FieldSelector with Lucene 2.3.2
Date Wed, 16 Mar 2011 15:17:41 GMT

I am trying to speed up access to the data in my results Documents and 
was wondering if FieldSelector might be the way forward?    After my 
search, I end up with an ArrayList of Documents, from each of which I 
need to extract certain fields and their values as key/value pairs in a 
HashMap.   Normally this is quick, but with large data sets (10,000+) it 
can take several seconds.  Here is the essence of the current code:

             for (Document doc : resultDocs) {
                 keyVals = getDocKeyValuePairs(doc, fields);
                 if (keyVals != null) {

     private HashMap getDocKeyValuePairs(Document doc, List<String> 
fields) {

         HashMap keyValMap = new HashMap();
         String field;
         String value;

         for(int i = 0; i < fields.size(); i++) {
             field = fields.get(i);
             value = doc.get(field);

             if (value != null) {
                 keyValMap.put(field, value);

         return keyValMap;

I am aware that this code may not be efficient, so any suggestions 
welcomed.  Also, how would one apply a FieldSelector in this case?


- Chris

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message