Package org.opencms.search.fields
Class CmsMacroSearchFieldMapping
java.lang.Object
org.opencms.search.fields.CmsMacroSearchFieldMapping
- All Implemented Interfaces:
Serializable,I_CmsSearchFieldMapping
Field mapping to resolve macros as for gallery names.
The main purpose is to use stringtemplates for special mappings to Solr fields.
For this use case, define a parameter (via
xsd:annotation/xsd:appinfo/parameters/param and use a stringtemplate as value.
In the solr mapping, you just place %(stringtemplate:paramName).
Example (there is some element "Type" and in the parameters section of the schema, there's a param "eventKind"):
<searchsetting element="Type">
<solrfield targetfield="event-kind" sourcefield="*_s">
<mapping type="dynamic" class="org.opencms.search.fields.CmsSchemaParameterSearchFieldMapping">%(stringtemplate:eventKind)</mapping>
</solrfield>
</searchsetting>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.commons.logging.LogLogger for the class -
Constructor Summary
ConstructorsConstructorDescriptionPublic constructor for a new search field mapping.CmsMacroSearchFieldMapping(CmsSearchFieldMappingType type, String param) Public constructor for a new search field mapping. -
Method Summary
Modifier and TypeMethodDescriptionReturns the default value used for this field mapping in case no content is available.getParam()Returns the mapping parameter.getStringValue(CmsObject cms, CmsResource res, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Returns the String value extracted form the provided data according to the rules of this mapping type.getType()Returns the mapping type.voidsetDefaultValue(String defaultValue) Sets the default value for this field mapping in case no content is available.voidSets the locale, the mapping can examine when extracting the content.voidSets the mapping parameter.voidSets the mapping type as a String.voidSets the mapping type.
-
Field Details
-
LOG
Logger for the class
-
-
Constructor Details
-
CmsMacroSearchFieldMapping
public CmsMacroSearchFieldMapping()Public constructor for a new search field mapping. -
CmsMacroSearchFieldMapping
Public constructor for a new search field mapping.- Parameters:
type- the type to use, seesetType(CmsSearchFieldMappingType)param- the mapping parameter, seesetParam(String)
-
-
Method Details
-
getDefaultValue
Description copied from interface:I_CmsSearchFieldMappingReturns the default value used for this field mapping in case no content is available.- Specified by:
getDefaultValuein interfaceI_CmsSearchFieldMapping- Returns:
- the default value used for this field mapping in case no content is available
- See Also:
-
getParam
Description copied from interface:I_CmsSearchFieldMappingReturns the mapping parameter.The parameter is used depending on the implementation of the rules of the selected
CmsSearchFieldMappingType.- Specified by:
getParamin interfaceI_CmsSearchFieldMapping- Returns:
- the mapping parameter
- See Also:
-
getStringValue
public String getStringValue(CmsObject cms, CmsResource res, I_CmsExtractionResult extractionResult, List<CmsProperty> properties, List<CmsProperty> propertiesSearched) Description copied from interface:I_CmsSearchFieldMappingReturns the String value extracted form the provided data according to the rules of this mapping type.- Specified by:
getStringValuein interfaceI_CmsSearchFieldMapping- Parameters:
cms- the OpenCms context used for building the search indexres- 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 String value extracted form the provided data according to the rules of this mapping type
- See Also:
-
getType
Description copied from interface:I_CmsSearchFieldMappingReturns the mapping type.- Specified by:
getTypein interfaceI_CmsSearchFieldMapping- Returns:
- the mapping type
- See Also:
-
setDefaultValue
Description copied from interface:I_CmsSearchFieldMappingSets the default value for this field mapping in case no content is available.- Specified by:
setDefaultValuein interfaceI_CmsSearchFieldMapping- Parameters:
defaultValue- the default value to set- See Also:
-
setLocale
Description copied from interface:I_CmsSearchFieldMappingSets the locale, the mapping can examine when extracting the content. NOTE: This method is called byCmsDefaultXmlContentHandlerwhen dynamic search field mappings are created. Overwrite this default implementation if you need to map locale specific in your dynamic mapping.- Specified by:
setLocalein interfaceI_CmsSearchFieldMapping- Parameters:
locale- the locale of the index field that is filled by the mapping.- See Also:
-
setParam
Description copied from interface:I_CmsSearchFieldMappingSets the mapping parameter.The parameter is used depending on the implementation of the rules of the selected
CmsSearchFieldMappingType.- Specified by:
setParamin interfaceI_CmsSearchFieldMapping- Parameters:
param- the parameter to set- See Also:
-
setType
Description copied from interface:I_CmsSearchFieldMappingSets the mapping type.- Specified by:
setTypein interfaceI_CmsSearchFieldMapping- Parameters:
type- the type to set- See Also:
-
setType
Description copied from interface:I_CmsSearchFieldMappingSets the mapping type as a String.- Specified by:
setTypein interfaceI_CmsSearchFieldMapping- Parameters:
type- the name of the type to set- See Also:
-