Package org.opencms.search.solr
Class CmsSolrFieldConfiguration
java.lang.Object
org.opencms.search.fields.A_CmsSearchFieldConfiguration
org.opencms.search.fields.CmsSearchFieldConfiguration
org.opencms.search.solr.CmsSolrFieldConfiguration
- All Implemented Interfaces:
Serializable
,Comparable<I_CmsSearchFieldConfiguration>
,I_CmsSearchFieldConfiguration
The search field implementation for Solr.
- Since:
- 8.5.0
- See Also:
-
Field Summary
Fields inherited from class org.opencms.search.fields.CmsSearchFieldConfiguration
LAZY_FIELDS, STR_STANDARD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalFields
(List<CmsSolrField> additionalFields) Adds the additional fields to the configuration, if they are not null.protected I_CmsSearchDocument
appendAdditionalValuesToDcoument
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Overriding this method allows to append some 'extra' values/fields to a document without overriding theCmsSearchFieldConfiguration.createDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.I_CmsSearchIndex, org.opencms.search.extractors.I_CmsExtractionResult)
method itself.protected I_CmsSearchDocument
appendDates
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Extends the given document by fields for date of creation, content and last modification.protected I_CmsSearchDocument
appendFieldMapping
(I_CmsSearchDocument document, CmsSearchField sfield, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Extends the given document by the mappings for the given field.protected I_CmsSearchDocument
appendFieldMappings
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Extends the given document by the configured field mappings.protected I_CmsSearchDocument
appendFieldMappingsFromElementsOnThePage
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, List<String> systemFields) Adds search fields from elements on a container page to a container page's document.protected I_CmsSearchDocument
appendLocales
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Extends the given document by the "res_locales" field.protected I_CmsSearchDocument
appendProperties
(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Appends all direct properties, that are not empty or white space only to the document.getContentLocales
(CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction) Retrieves the locales for an content, that is whether an XML content nor an XML page.Returns all configured Solr fields.protected Set<CmsSearchField>
getXSDMappings
(CmsObject cms, CmsResource resource) Returns the search field mappings declared within the XSD.protected Set<CmsSearchField>
getXSDMappingsForPage
(CmsObject cms, CmsResource resource) Returns the search field mappings declared within the XSD that should be applied to the container page.void
init()
Initializes this field configuration.Methods inherited from class org.opencms.search.fields.CmsSearchFieldConfiguration
addUninvertingMappings, appendCategories, appendContentBlob, appendFileSize, appendPath, appendType, createDocument, getIndex, getLocaleExtendedName, getLocaleExtendedName, getParentFolderTokens, setIndex
Methods inherited from class org.opencms.search.fields.A_CmsSearchFieldConfiguration
addField, compareTo, equals, getDescription, getField, getFieldNames, getFields, getName, hashCode, setDescription, setName
-
Constructor Details
-
CmsSolrFieldConfiguration
public CmsSolrFieldConfiguration()Default constructor.
-
-
Method Details
-
addAdditionalFields
Adds the additional fields to the configuration, if they are not null.- Parameters:
additionalFields
- the additional fields to add
-
getSolrFields
Returns all configured Solr fields.- Returns:
- all configured Solr fields
-
init
Description copied from interface:I_CmsSearchFieldConfiguration
Initializes this field configuration.- Specified by:
init
in interfaceI_CmsSearchFieldConfiguration
- Overrides:
init
in classA_CmsSearchFieldConfiguration
- See Also:
-
appendAdditionalValuesToDcoument
protected I_CmsSearchDocument appendAdditionalValuesToDcoument(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Overriding this method allows to append some 'extra' values/fields to a document without overriding theCmsSearchFieldConfiguration.createDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.I_CmsSearchIndex, org.opencms.search.extractors.I_CmsExtractionResult)
method itself.The method
CmsSearchFieldConfiguration.createDocument(org.opencms.file.CmsObject, org.opencms.file.CmsResource, org.opencms.search.I_CmsSearchIndex, org.opencms.search.extractors.I_CmsExtractionResult)
reads all properties of the current resource which is an expensive operation. In order to avoid reading those properties twice, this method has been introduced.Compared with all the other appender methods the name of this method is generic.
In this default implementation the document is returned unchanged.
- Overrides:
appendAdditionalValuesToDcoument
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextractionResult
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by resource category information
- See Also:
-
appendDates
protected I_CmsSearchDocument appendDates(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Extends the given document by fields for date of creation, content and last modification.- Overrides:
appendDates
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextractionResult
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by fields for date of creation, content and last modification
- See Also:
-
appendFieldMapping
protected I_CmsSearchDocument appendFieldMapping(I_CmsSearchDocument document, CmsSearchField sfield, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Extends the given document by the mappings for the given field.- Overrides:
appendFieldMapping
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendsfield
- the field to create the mappings forcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextractionResult
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by the mappings for the given field
- See Also:
-
appendFieldMappings
protected I_CmsSearchDocument appendFieldMappings(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Extends the given document by the configured field mappings.- Overrides:
appendFieldMappings
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextractionResult
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by the configured field mappings
- See Also:
-
appendFieldMappingsFromElementsOnThePage
protected I_CmsSearchDocument appendFieldMappingsFromElementsOnThePage(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, List<String> systemFields) Adds search fields from elements on a container page to a container page's document.- Parameters:
document
- The document for the container pagecms
- The current CmsObjectresource
- The resource of the container pagesystemFields
- The list of field names for fields where mappings to should be discarded, since these fields are used system internally.- Returns:
- the manipulated document
-
appendLocales
protected I_CmsSearchDocument appendLocales(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Extends the given document by the "res_locales" field.- Overrides:
appendLocales
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextraction
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by the resource locales
- See Also:
-
appendProperties
protected I_CmsSearchDocument appendProperties(I_CmsSearchDocument document, CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from class:CmsSearchFieldConfiguration
Appends all direct properties, that are not empty or white space only to the document.- Overrides:
appendProperties
in classCmsSearchFieldConfiguration
- Parameters:
document
- the document to extendcms
- the OpenCms context used for building the search indexresource
- the resource that is indexedextraction
- the plain text extraction result from the resourceproperties
- the list of all properties directly attached to the resource (not searched)propertiesSearched
- the list of all searched properties of the resource- Returns:
- the document extended by resource category information
- See Also:
-
getContentLocales
protected List<Locale> getContentLocales(CmsObject cms, CmsResource resource, I_CmsExtractionResult extraction) Retrieves the locales for an content, that is whether an XML content nor an XML page.Uses following strategy:
- first by file name
- then by detection and
- otherwise take the first configured default locale for this resource
- Parameters:
cms
- the current CmsObjectresource
- the resource to get the content locales forextraction
- the extraction result- Returns:
- the determined locales for the given resource
-
getXSDMappings
Returns the search field mappings declared within the XSD.- Parameters:
cms
- the CmsObjectresource
- the resource- Returns:
- the fields to map
-
getXSDMappingsForPage
Returns the search field mappings declared within the XSD that should be applied to the container page.- Parameters:
cms
- the CmsObjectresource
- the resource- Returns:
- the fields to map
-