1 16 17 package info.jtrac.lucene; 18 19 import org.apache.lucene.document.Document; 20 import org.springmodules.lucene.search.core.HitExtractor; 21 22 27 public class ItemIdHitExtractor implements HitExtractor { 28 29 public Long mapHit(int i, Document document, float f) { 30 String type = document.get("type"); 31 if (type == null) { 32 return null; 33 } 34 if (type.equals("item")) { 35 String id = document.get("id"); 36 return new Long (id); 37 } else if (type.equals("history")) { 38 String itemId = document.get("itemId"); 39 return new Long (itemId); 40 } else { 41 throw new RuntimeException ("Unexpected lucene search result: " + document); 42 } 43 } 44 45 } 46 | Popular Tags |