public class CmsLuceneDocument extends java.lang.Object implements I_CmsSearchDocument
| Modifier and Type | Field and Description |
|---|---|
static org.apache.lucene.document.FieldType |
NOT_STORED_ANALYSED_TYPE
Type for a stored-only field.
|
static org.apache.lucene.document.FieldType |
STORED_ANALYSED_TYPE
Type for a stored-and analyzed fields.
|
static org.apache.lucene.document.FieldType |
STORED_NOT_ANALYSED_TYPE
Type for a stored-only field.
|
SEARCH_PRIORITY_HIGH_VALUE, SEARCH_PRIORITY_LOW_VALUE, SEARCH_PRIORITY_MAX_VALUE, SEARCH_PRIORITY_NORMAL_VALUE, VFS_DOCUMENT_KEY_PREFIX| Constructor and Description |
|---|
CmsLuceneDocument(org.apache.lucene.document.Document doc)
Public constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addCategoryField(java.util.List<CmsCategory> categories)
Adds the list of the given categories to this document.
|
void |
addContentField(byte[] data)
Adds the given content byte array to this document.
|
void |
addContentLocales(java.util.Collection<java.util.Locale> locales)
Adds the locales of the content to this document.
|
void |
addDateField(java.lang.String name,
long date,
boolean analyzed)
Puts the given date into the field with the given name.
|
void |
addFileSizeField(int length)
Adds the given file size as field to this document.
|
void |
addPathField(java.lang.String rootPath)
Puts the given path into this document.
|
void |
addResourceLocales(java.util.Collection<java.util.Locale> locales)
Adds the locales of the resource to this document.
|
void |
addRootPathField(java.lang.String rootPath)
Puts the given root path into its default field.
|
void |
addSearchField(CmsSearchField field,
java.lang.String value)
Adds a dynamic search field to the index.
|
void |
addSuffixField(java.lang.String suffix)
Adds the suffix field to the document.
|
void |
addTypeField(java.lang.String typeName)
Adds the resource type to this document.
|
byte[] |
getContentBlob()
Returns the content blob of this document.
|
static java.lang.String |
getDateTerms(long date)
Generate a list of date terms for the optimized date range search.
|
java.lang.Object |
getDocument()
Returns the concrete document as Object to be cast if necessary.
|
java.util.List<java.lang.String> |
getFieldNames()
Returns all field names of this document.
|
java.util.Date |
getFieldValueAsDate(java.lang.String fieldName)
Tries to return the value of the field for the given name as Date,
null if the field is empty or if the field is not of the type date. |
java.lang.String |
getFieldValueAsString(java.lang.String fieldName)
Returns the value of the field for the given name as String.
|
java.util.List<java.lang.String> |
getMultivaluedFieldAsStringList(java.lang.String fieldName)
Returns the values of a multi-valued field as list of strings.
|
java.lang.String |
getPath()
Returns the root path of the referenced VFS resource of this document.
|
float |
getScore()
Returns the score for this document.
|
java.lang.String |
getType()
Returns the resource type of the referenced VFS resource of this document.
|
void |
setScore(float score)
Sets the score for this document.
|
public static final org.apache.lucene.document.FieldType NOT_STORED_ANALYSED_TYPE
public static final org.apache.lucene.document.FieldType STORED_ANALYSED_TYPE
public static final org.apache.lucene.document.FieldType STORED_NOT_ANALYSED_TYPE
public CmsLuceneDocument(org.apache.lucene.document.Document doc)
doc - the Lucene documentpublic static java.lang.String getDateTerms(long date)
date - the date for get the date terms forCmsSearchIndex.getDateRangeSpan(long, long)public void addCategoryField(java.util.List<CmsCategory> categories)
I_CmsSearchDocumentaddCategoryField in interface I_CmsSearchDocumentcategories - the categories to addI_CmsSearchDocument.addCategoryField(java.util.List)public void addContentField(byte[] data)
I_CmsSearchDocumentaddContentField in interface I_CmsSearchDocumentdata - the content to addI_CmsSearchDocument.addContentField(byte[])public void addContentLocales(java.util.Collection<java.util.Locale> locales)
I_CmsSearchDocumentaddContentLocales in interface I_CmsSearchDocumentlocales - the locales of the contentI_CmsSearchDocument.addContentLocales(java.util.Collection)public void addDateField(java.lang.String name, long date, boolean analyzed)
I_CmsSearchDocumentaddDateField in interface I_CmsSearchDocumentname - the name to put the date indate - the date to pu into the fieldanalyzed - true if the inserted value should be analyzableI_CmsSearchDocument.addDateField(java.lang.String, long, boolean)public void addFileSizeField(int length)
I_CmsSearchDocumentaddFileSizeField in interface I_CmsSearchDocumentlength - the lengthI_CmsSearchDocument.addFileSizeField(int)public void addPathField(java.lang.String rootPath)
I_CmsSearchDocumentaddPathField in interface I_CmsSearchDocumentrootPath - the given path into this documentI_CmsSearchDocument.addPathField(java.lang.String)public void addResourceLocales(java.util.Collection<java.util.Locale> locales)
I_CmsSearchDocumentaddResourceLocales in interface I_CmsSearchDocumentlocales - the locales of the resourceI_CmsSearchDocument.addResourceLocales(java.util.Collection)public void addRootPathField(java.lang.String rootPath)
I_CmsSearchDocumentaddRootPathField in interface I_CmsSearchDocumentrootPath - the root path to put into the fieldI_CmsSearchDocument.addRootPathField(java.lang.String)public void addSearchField(CmsSearchField field, java.lang.String value)
I_CmsSearchDocumentaddSearchField in interface I_CmsSearchDocumentfield - the fieldvalue - the valueI_CmsSearchDocument.addSearchField(org.opencms.search.fields.CmsSearchField, java.lang.String)public void addSuffixField(java.lang.String suffix)
I_CmsSearchDocument
Example
'html' for a file named 'article.html'
addSuffixField in interface I_CmsSearchDocumentsuffix - the suffix to addI_CmsSearchDocument.addSuffixField(java.lang.String)public void addTypeField(java.lang.String typeName)
I_CmsSearchDocumentaddTypeField in interface I_CmsSearchDocumenttypeName - the resource type name.I_CmsSearchDocument.addTypeField(java.lang.String)public byte[] getContentBlob()
I_CmsSearchDocumentgetContentBlob in interface I_CmsSearchDocumentI_CmsSearchDocument.getContentBlob()public java.lang.Object getDocument()
I_CmsSearchDocumentgetDocument in interface I_CmsSearchDocumentI_CmsSearchDocument.getDocument()public java.util.List<java.lang.String> getFieldNames()
I_CmsSearchDocumentgetFieldNames in interface I_CmsSearchDocumentI_CmsSearchDocument.getFieldNames()public java.util.Date getFieldValueAsDate(java.lang.String fieldName)
I_CmsSearchDocumentnull if the field is empty or if the field is not of the type date.getFieldValueAsDate in interface I_CmsSearchDocumentfieldName - the name of the field to get the Date value fornullI_CmsSearchDocument.getFieldValueAsDate(java.lang.String)public java.lang.String getFieldValueAsString(java.lang.String fieldName)
I_CmsSearchDocumentgetFieldValueAsString in interface I_CmsSearchDocumentfieldName - the name of the field to get the String value fornull if emptyI_CmsSearchDocument.getFieldValueAsString(java.lang.String)public java.util.List<java.lang.String> getMultivaluedFieldAsStringList(java.lang.String fieldName)
I_CmsSearchDocumentgetMultivaluedFieldAsStringList in interface I_CmsSearchDocumentfieldName - the name of the multivalued field to get the values from.I_CmsSearchDocument.getMultivaluedFieldAsStringList(java.lang.String)public java.lang.String getPath()
I_CmsSearchDocumentgetPath in interface I_CmsSearchDocumentI_CmsSearchDocument.getPath()public float getScore()
I_CmsSearchDocumentgetScore in interface I_CmsSearchDocumentI_CmsSearchDocument.getScore()public java.lang.String getType()
I_CmsSearchDocumentgetType in interface I_CmsSearchDocumentI_CmsSearchDocument.getType()public void setScore(float score)
I_CmsSearchDocumentsetScore in interface I_CmsSearchDocumentscore - the scoreI_CmsSearchDocument.setScore(float)