1 26 27 29 package de.nava.informa.search; 30 31 import de.nava.informa.core.ItemIF; 32 33 import org.apache.lucene.document.Document; 34 import org.apache.lucene.document.Field; 35 import org.apache.lucene.document.DateField; 36 37 43 public class ItemDocument implements ItemFieldConstants { 44 45 private ItemDocument() { 46 } 47 48 66 public static Document makeDocument(ItemIF item) { 67 Document doc = new Document(); 68 doc.add(Field.Text(TITLE, item.getTitle())); 69 doc.add(Field.Text(DESCRIPTION, item.getDescription())); 70 doc.add(Field.Text(TITLE_AND_DESC, item.getTitle() + " " + 71 item.getDescription())); 72 if (item.getFound() != null) { 74 doc.add(Field.Keyword(DATE_FOUND, 75 DateField.dateToString(item.getFound()))); 76 } 77 doc.add(Field.UnIndexed(ITEM_ID, Long.toString(item.getId()))); 79 if (item.getChannel() != null) { 81 doc.add(Field.UnIndexed(CHANNEL_ID, 82 Long.toString(item.getChannel().getId()))); 83 } 84 return doc; 85 } 86 87 } 88 | Popular Tags |