lucene-java-user mailing list archives

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

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) {
                     resultsList.add(keyVals);
                 }
             }

     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?

Thanks

- Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message