org.opencms.search.solr
Class CmsSolrDocument

java.lang.Object
  extended by org.opencms.search.solr.CmsSolrDocument
All Implemented Interfaces:
I_CmsSearchDocument

public class CmsSolrDocument
extends java.lang.Object
implements I_CmsSearchDocument

A search document implementation for Solr indexes.

Since:
8.5.0

Field Summary
 
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
CmsSolrDocument(org.apache.solr.common.SolrDocument doc)
          Public constructor to create a encapsulate a Solr document.
CmsSolrDocument(org.apache.solr.common.SolrInputDocument doc)
          Public constructor to create a encapsulate a Solr document.
 
Method Summary
 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.List<java.util.Locale> locales)
          Adds the locales of the content to this document.
 void addDateField(java.lang.String name, long time, boolean analyzed)
          Puts the given date into the field with the given name.
 void addDocumentDependency(CmsObject cms, CmsDocumentDependency resDeps)
          Adds the given document dependency to this document.
 void addFileSizeField(int length)
          Adds the given file size as field to this document.
 void addMultiValuedField(java.lang.String fieldName, java.util.List<java.lang.String> values)
          Adds a multi-valued field.
 void addPathField(java.lang.String rootPath)
          Puts the given path into this document.
 void addResourceLocales(java.util.List<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 sfield, 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 type)
          Adds the resource type to this document.
 byte[] getContentBlob()
          Returns the content blob of this document.
 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 a list of Strings representing the values of an multi valued field.
 java.lang.String getPath()
          Returns the root path of the referenced VFS resource of this document.
 float getScore()
          Returns the score for this document.
 org.apache.solr.common.SolrDocument getSolrDocument()
          Returns the Solr document.
 java.lang.String getType()
          Returns the resource type of the referenced VFS resource of this document.
 void setBoost(float boost)
          Sets the boost factor for the whole document.
 void setId(CmsUUID structureId)
          Sets the id of this document.
 void setScore(float score)
          Sets the score for this document.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmsSolrDocument

public CmsSolrDocument(org.apache.solr.common.SolrDocument doc)
Public constructor to create a encapsulate a Solr document.

Parameters:
doc - the Solr document

CmsSolrDocument

public CmsSolrDocument(org.apache.solr.common.SolrInputDocument doc)
Public constructor to create a encapsulate a Solr document.

Parameters:
doc - the Solr document
Method Detail

addCategoryField

public void addCategoryField(java.util.List<CmsCategory> categories)
Description copied from interface: I_CmsSearchDocument
Adds the list of the given categories to this document.

Specified by:
addCategoryField in interface I_CmsSearchDocument
Parameters:
categories - the categories to add
See Also:
I_CmsSearchDocument.addCategoryField(java.util.List)

addContentField

public void addContentField(byte[] data)
Description copied from interface: I_CmsSearchDocument
Adds the given content byte array to this document.

Specified by:
addContentField in interface I_CmsSearchDocument
Parameters:
data - the content to add
See Also:
I_CmsSearchDocument.addContentField(byte[])

addContentLocales

public void addContentLocales(java.util.List<java.util.Locale> locales)
Description copied from interface: I_CmsSearchDocument
Adds the locales of the content to this document.

Specified by:
addContentLocales in interface I_CmsSearchDocument
Parameters:
locales - the locales of the content
See Also:
I_CmsSearchDocument.addContentLocales(java.util.List)

addDateField

public void addDateField(java.lang.String name,
                         long time,
                         boolean analyzed)
Description copied from interface: I_CmsSearchDocument
Puts the given date into the field with the given name.

Specified by:
addDateField in interface I_CmsSearchDocument
Parameters:
name - the name to put the date in
time - the date to pu into the field
analyzed - true if the inserted value should be analyzable
See Also:
I_CmsSearchDocument.addDateField(java.lang.String, long, boolean)

addDocumentDependency

public void addDocumentDependency(CmsObject cms,
                                  CmsDocumentDependency resDeps)
Adds the given document dependency to this document.

Parameters:
cms - the current CmsObject
resDeps - the dependency

addFileSizeField

public void addFileSizeField(int length)
Description copied from interface: I_CmsSearchDocument
Adds the given file size as field to this document.

Specified by:
addFileSizeField in interface I_CmsSearchDocument
Parameters:
length - the length
See Also:
I_CmsSearchDocument.addFileSizeField(int)

addMultiValuedField

public void addMultiValuedField(java.lang.String fieldName,
                                java.util.List<java.lang.String> values)
Adds a multi-valued field.

Parameters:
fieldName - the field name to put the values in
values - the values to put in the field

addPathField

public void addPathField(java.lang.String rootPath)
Description copied from interface: I_CmsSearchDocument
Puts the given path into this document.

Specified by:
addPathField in interface I_CmsSearchDocument
Parameters:
rootPath - the given path into this document
See Also:
I_CmsSearchDocument.addPathField(java.lang.String)

addResourceLocales

public void addResourceLocales(java.util.List<java.util.Locale> locales)
Description copied from interface: I_CmsSearchDocument
Adds the locales of the resource to this document.

Specified by:
addResourceLocales in interface I_CmsSearchDocument
Parameters:
locales - the locales of the resource
See Also:
I_CmsSearchDocument.addResourceLocales(java.util.List)

addRootPathField

public void addRootPathField(java.lang.String rootPath)
Description copied from interface: I_CmsSearchDocument
Puts the given root path into its default field.

Specified by:
addRootPathField in interface I_CmsSearchDocument
Parameters:
rootPath - the root path to put into the field
See Also:
I_CmsSearchDocument.addRootPathField(java.lang.String)

addSearchField

public void addSearchField(CmsSearchField sfield,
                           java.lang.String value)
Description copied from interface: I_CmsSearchDocument
Adds a dynamic search field to the index.

Specified by:
addSearchField in interface I_CmsSearchDocument
Parameters:
sfield - the field
value - the value
See Also:
I_CmsSearchDocument.addSearchField(org.opencms.search.fields.CmsSearchField, java.lang.String)

addSuffixField

public void addSuffixField(java.lang.String suffix)
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 interface I_CmsSearchDocument
Parameters:
suffix - the suffix to add
See Also:
I_CmsSearchDocument.addSuffixField(java.lang.String)

addTypeField

public void addTypeField(java.lang.String type)
Description copied from interface: I_CmsSearchDocument
Adds the resource type to this document.

Specified by:
addTypeField in interface I_CmsSearchDocument
See Also:
I_CmsSearchDocument.addTypeField(java.lang.String)

getContentBlob

public byte[] getContentBlob()
Description copied from interface: I_CmsSearchDocument
Returns the content blob of this document.

Specified by:
getContentBlob in interface I_CmsSearchDocument
Returns:
the content blob
See Also:
I_CmsSearchDocument.getContentBlob()

getDocument

public java.lang.Object getDocument()
Description copied from interface: I_CmsSearchDocument
Returns the concrete document as Object to be cast if necessary.

Specified by:
getDocument in interface I_CmsSearchDocument
Returns:
the document as Object
See Also:
I_CmsSearchDocument.getDocument()

getFieldNames

public java.util.List<java.lang.String> getFieldNames()
Description copied from interface: I_CmsSearchDocument
Returns all field names of this document.

Specified by:
getFieldNames in interface I_CmsSearchDocument
Returns:
the field names
See Also:
I_CmsSearchDocument.getFieldNames()

getFieldValueAsDate

public java.util.Date getFieldValueAsDate(java.lang.String fieldName)
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 interface I_CmsSearchDocument
Parameters:
fieldName - the name of the field to get the Date value for
Returns:
the date or null
See Also:
I_CmsSearchDocument.getFieldValueAsDate(java.lang.String)

getFieldValueAsString

public java.lang.String getFieldValueAsString(java.lang.String fieldName)
Description copied from interface: I_CmsSearchDocument
Returns the value of the field for the given name as String.

Specified by:
getFieldValueAsString in interface I_CmsSearchDocument
Parameters:
fieldName - the name of the field to get the String value for
Returns:
the String value or null if empty
See Also:
I_CmsSearchDocument.getFieldValueAsString(java.lang.String)

getMultivaluedFieldAsStringList

public java.util.List<java.lang.String> getMultivaluedFieldAsStringList(java.lang.String fieldName)
Description copied from interface: I_CmsSearchDocument
Returns a list of Strings representing the values of an multi valued field.

Specified by:
getMultivaluedFieldAsStringList in interface I_CmsSearchDocument
Parameters:
fieldName - the name of the multi valued field to get the content of
Returns:
the list of Strings, or null
See Also:
I_CmsSearchDocument.getMultivaluedFieldAsStringList(java.lang.String)

getPath

public java.lang.String getPath()
Description copied from interface: I_CmsSearchDocument
Returns the root path of the referenced VFS resource of this document.

Specified by:
getPath in interface I_CmsSearchDocument
Returns:
the root path
See Also:
I_CmsSearchDocument.getPath()

getScore

public float getScore()
Description copied from interface: I_CmsSearchDocument
Returns the score for this document.

Specified by:
getScore in interface I_CmsSearchDocument
Returns:
the score
See Also:
I_CmsSearchDocument.getScore()

getSolrDocument

public org.apache.solr.common.SolrDocument getSolrDocument()
Returns the Solr document.

Returns:
the Solr document

getType

public java.lang.String getType()
Description copied from interface: I_CmsSearchDocument
Returns the resource type of the referenced VFS resource of this document.

Specified by:
getType in interface I_CmsSearchDocument
Returns:
the type
See Also:
I_CmsSearchDocument.getType()

setBoost

public void setBoost(float boost)
Description copied from interface: I_CmsSearchDocument
Sets the boost factor for the whole document.

Specified by:
setBoost in interface I_CmsSearchDocument
Parameters:
boost - the factor to set
See Also:
I_CmsSearchDocument.setBoost(float)

setId

public void setId(CmsUUID structureId)
Sets the id of this document.

Parameters:
structureId - the structure id to use

setScore

public void setScore(float score)
Description copied from interface: I_CmsSearchDocument
Sets the score for this document.

Specified by:
setScore in interface I_CmsSearchDocument
Parameters:
score - the score
See Also:
I_CmsSearchDocument.setScore(float)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()