/**
* Generate a lucene document from the data stored in this document
* @return
*/
public Document getLuceneDocument() {
Document document = new Document();
document.add( createField(TITLE_FIELD_NAME,getTitle(), Field.Index.ANALYZED,4) );
document.add( createField(DESCRIPTION_FIELD_NAME,getDescription(), Field.Index.ANALYZED,2) );
document.add( createField(CONTENT_FIELD_NAME,getContent(), Field.Index.ANALYZED, 0.5f ) );
document.add(new Field(RESOURCEURL_FIELD_NAME,getResourceUrl(), Field.Store.YES, Field.Index.NOT_ANALYZED) );//SET to ANALYZED
document.add(new Field(DOCUMENTTYPE_FIELD_NAME,getDocumentType(), Field.Store.YES, Field.Index.NOT_ANALYZED) );
if(getCssIcon() != null)
document.add(new Field(CSS_ICON,getCssIcon(), Field.Store.YES, Field.Index.NOT_ANALYZED) );
document.add(new Field(FILETYPE_FIELD_NAME,getFileType(), Field.Store.YES, Field.Index.NOT_ANALYZED) );
document.add( createField(AUTHOR_FIELD_NAME,getAuthor(), Field.Index.ANALYZED, 2) );
try {
if(getCreatedDate() != null) {
document.add(new Field(CREATED_FIELD_NAME,DateTools.dateToString(getCreatedDate(), DateTools.Resolution.DAY), Field.Store.YES, Field.Index.ANALYZED) );
}
}catch (Exception ex) {
// No createdDate set => does not add field
}
try {
if(getLastChange() != null) {
document.add(new Field(CHANGED_FIELD_NAME,DateTools.dateToString(getLastChange(), DateTools.Resolution.DAY), Field.Store.YES, Field.Index.ANALYZED) );
}
}catch (Exception ex) {
// No changedDate set => does not add field
}
try {
if(getTimestamp() != null) {
document.add(new Field(TIME_STAMP_NAME,DateTools.dateToString(getTimestamp(), DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.NO) );
}
}catch (Exception ex) {
// No changedDate set => does not add field
}
// Add various metadata
if (metadata != null) {
for (Entry<String, List<String>> metaDataEntry : metadata.entrySet()) {
String key = metaDataEntry.getKey();
List<String> values = metaDataEntry.getValue();
for (String value : values) {
//FIXME:FG: tokenized or not? which priority
document.add( createField(key, value, Field.Index.ANALYZED, 2) );
}
}
}
document.add(new Field(PARENT_CONTEXT_TYPE_FIELD_NAME,getParentContextType(), Field.Store.YES, Field.Index.ANALYZED) );
document.add(new Field(PARENT_CONTEXT_NAME_FIELD_NAME,getParentContextName(), Field.Store.YES, Field.Index.ANALYZED) );
return document;
}