Package org.opencms.search
Class CmsLuceneDocument
java.lang.Object
org.opencms.search.CmsLuceneDocument
- All Implemented Interfaces:
I_CmsSearchDocument
A Lucene search document implementation.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final org.apache.lucene.document.FieldType
Type for a stored-only field.static final org.apache.lucene.document.FieldType
Type for a stored-and analyzed fields.static final org.apache.lucene.document.FieldType
Type for a stored-only field.Fields inherited from interface org.opencms.search.I_CmsSearchDocument
SEARCH_PRIORITY_HIGH_VALUE, SEARCH_PRIORITY_LOW_VALUE, SEARCH_PRIORITY_MAX_VALUE, SEARCH_PRIORITY_NORMAL_VALUE, VFS_DOCUMENT_KEY_PREFIX
-
Constructor Summary
ConstructorDescriptionCmsLuceneDocument
(org.apache.lucene.document.Document doc) Public constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCategoryField
(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
(Collection<Locale> locales) Adds the locales of the content to this document.void
addDateField
(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
(String rootPath) Puts the given path into this document.void
addResourceLocales
(Collection<Locale> locales) Adds the locales of the resource to this document.void
addRootPathField
(String rootPath) Puts the given root path into its default field.void
addSearchField
(CmsSearchField field, String value) Adds a dynamic search field to the index.void
addSuffixField
(String suffix) Adds the suffix field to the document.void
addTypeField
(String typeName) Adds the resource type to this document.byte[]
Returns the content blob of this document.static String
getDateTerms
(long date) Generate a list of date terms for the optimized date range search.Returns the concrete document as Object to be cast if necessary.Returns all field names of this document.getFieldValueAsDate
(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.getFieldValueAsString
(String fieldName) Returns the value of the field for the given name as String.getMultivaluedFieldAsStringList
(String fieldName) Returns the values of a multi-valued field as list of strings.getPath()
Returns the root path of the referenced VFS resource of this document.float
getScore()
Returns the score for this document.getType()
Returns the resource type of the referenced VFS resource of this document.void
setScore
(float score) Sets the score for this document.
-
Field Details
-
NOT_STORED_ANALYSED_TYPE
Type for a stored-only field. -
STORED_ANALYSED_TYPE
Type for a stored-and analyzed fields. -
STORED_NOT_ANALYSED_TYPE
Type for a stored-only field.
-
-
Constructor Details
-
CmsLuceneDocument
Public constructor.- Parameters:
doc
- the Lucene document
-
-
Method Details
-
getDateTerms
Generate a list of date terms for the optimized date range search.- Parameters:
date
- the date for get the date terms for- Returns:
- a list of date terms for the optimized date range search
- See Also:
-
addCategoryField
Description copied from interface:I_CmsSearchDocument
Adds the list of the given categories to this document.- Specified by:
addCategoryField
in interfaceI_CmsSearchDocument
- Parameters:
categories
- the categories to add- See Also:
-
addContentField
Description copied from interface:I_CmsSearchDocument
Adds the given content byte array to this document.- Specified by:
addContentField
in interfaceI_CmsSearchDocument
- Parameters:
data
- the content to add- See Also:
-
addContentLocales
Description copied from interface:I_CmsSearchDocument
Adds the locales of the content to this document.- Specified by:
addContentLocales
in interfaceI_CmsSearchDocument
- Parameters:
locales
- the locales of the content- See Also:
-
addDateField
Description copied from interface:I_CmsSearchDocument
Puts the given date into the field with the given name.- Specified by:
addDateField
in interfaceI_CmsSearchDocument
- Parameters:
name
- the name to put the date indate
- the date to pu into the fieldanalyzed
-true
if the inserted value should be analyzable- See Also:
-
addFileSizeField
Description copied from interface:I_CmsSearchDocument
Adds the given file size as field to this document.- Specified by:
addFileSizeField
in interfaceI_CmsSearchDocument
- Parameters:
length
- the length- See Also:
-
addPathField
Description copied from interface:I_CmsSearchDocument
Puts the given path into this document.- Specified by:
addPathField
in interfaceI_CmsSearchDocument
- Parameters:
rootPath
- the given path into this document- See Also:
-
addResourceLocales
Description copied from interface:I_CmsSearchDocument
Adds the locales of the resource to this document.- Specified by:
addResourceLocales
in interfaceI_CmsSearchDocument
- Parameters:
locales
- the locales of the resource- See Also:
-
addRootPathField
Description copied from interface:I_CmsSearchDocument
Puts the given root path into its default field.- Specified by:
addRootPathField
in interfaceI_CmsSearchDocument
- Parameters:
rootPath
- the root path to put into the field- See Also:
-
addSearchField
Description copied from interface:I_CmsSearchDocument
Adds a dynamic search field to the index.- Specified by:
addSearchField
in interfaceI_CmsSearchDocument
- Parameters:
field
- the fieldvalue
- the value- See Also:
-
addSuffixField
Description copied from interface:I_CmsSearchDocument
Adds the suffix field to the document. This field should contain the resource suffix.Example
'html' for a file named 'article.html'
- Specified by:
addSuffixField
in interfaceI_CmsSearchDocument
- Parameters:
suffix
- the suffix to add- See Also:
-
addTypeField
Description copied from interface:I_CmsSearchDocument
Adds the resource type to this document.- Specified by:
addTypeField
in interfaceI_CmsSearchDocument
- Parameters:
typeName
- the resource type name.- See Also:
-
getContentBlob
Description copied from interface:I_CmsSearchDocument
Returns the content blob of this document.- Specified by:
getContentBlob
in interfaceI_CmsSearchDocument
- Returns:
- the content blob
- See Also:
-
getDocument
Description copied from interface:I_CmsSearchDocument
Returns the concrete document as Object to be cast if necessary.- Specified by:
getDocument
in interfaceI_CmsSearchDocument
- Returns:
- the document as Object
- See Also:
-
getFieldNames
Description copied from interface:I_CmsSearchDocument
Returns all field names of this document.- Specified by:
getFieldNames
in interfaceI_CmsSearchDocument
- Returns:
- the field names
- See Also:
-
getFieldValueAsDate
Description copied from interface:I_CmsSearchDocument
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.- Specified by:
getFieldValueAsDate
in interfaceI_CmsSearchDocument
- Parameters:
fieldName
- the name of the field to get the Date value for- Returns:
- the date or
null
- See Also:
-
getFieldValueAsString
Description copied from interface:I_CmsSearchDocument
Returns the value of the field for the given name as String.- Specified by:
getFieldValueAsString
in interfaceI_CmsSearchDocument
- Parameters:
fieldName
- the name of the field to get the String value for- Returns:
- the String value or
null
if empty - See Also:
-
getMultivaluedFieldAsStringList
Description copied from interface:I_CmsSearchDocument
Returns the values of a multi-valued field as list of strings.- Specified by:
getMultivaluedFieldAsStringList
in interfaceI_CmsSearchDocument
- Parameters:
fieldName
- the name of the multivalued field to get the values from.- Returns:
- the values of a multi-valued field as list of strings.
- See Also:
-
getPath
Description copied from interface:I_CmsSearchDocument
Returns the root path of the referenced VFS resource of this document.- Specified by:
getPath
in interfaceI_CmsSearchDocument
- Returns:
- the root path
- See Also:
-
getScore
Description copied from interface:I_CmsSearchDocument
Returns the score for this document.- Specified by:
getScore
in interfaceI_CmsSearchDocument
- Returns:
- the score
- See Also:
-
getType
Description copied from interface:I_CmsSearchDocument
Returns the resource type of the referenced VFS resource of this document.- Specified by:
getType
in interfaceI_CmsSearchDocument
- Returns:
- the type
- See Also:
-
setScore
Description copied from interface:I_CmsSearchDocument
Sets the score for this document.- Specified by:
setScore
in interfaceI_CmsSearchDocument
- Parameters:
score
- the score- See Also:
-