Class SolrContentIndexer

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.content.indexing.solr.SolrContentIndexer
All Implemented Interfaces:
SolrFieldNames, LogEnabled, Component, Serviceable

Component for Content indexing into a Solr server.
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • indexContent

      public void indexContent(Content content, org.apache.solr.common.SolrInputDocument document, List<org.apache.solr.common.SolrInputDocument> additionalDocuments) throws Exception
      Populate a solr input document by adding fields to index into it.
      Parameters:
      content - The content to index
      document - The main solr document to index into
      additionalDocuments - The additional documents for repeater instances
      Throws:
      Exception - if an error occurred while indexing
    • indexContentTitle

      protected void indexContentTitle(Content content, org.apache.solr.common.SolrInputDocument document)
      Index the content title
      Parameters:
      content - The title
      document - The main solr document to index into
    • indexSystemProperties

      protected void indexSystemProperties(Content content, org.apache.solr.common.SolrInputDocument document)
      Index the system properties of a content.
      Parameters:
      content - The content to index.
      document - The solr document to index into.
    • indexAllContentTypes

      protected void indexAllContentTypes(String cTypeId, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index the content type and all its supertypes in the given document (recursively).
      Parameters:
      cTypeId - The ID of the content type to index.
      document - The solr document to index into.
      fieldName - The field name.
    • indexModelFields

      protected void indexModelFields(Content content, org.apache.solr.common.SolrInputDocument document, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Index the fields specified in the indexation model.
      Parameters:
      content - The content to index.
      document - The main content solr document.
      additionalDocuments - The additional documents for repeater instances.
    • indexPartialSystemProperty

      public boolean indexPartialSystemProperty(Content content, String propertyId, org.apache.solr.common.SolrInputDocument document) throws Exception
      Populate a Solr input document by adding fields for a single system property.
      Parameters:
      content - The content to index
      propertyId - The system property ID.
      document - The solr document
      Returns:
      true if there are partial update to apply
      Throws:
      Exception - if an error occurred
    • findAndIndexMetadata

      protected void findAndIndexMetadata(Content content, String[] pathSegments, CompositeMetadata metadata, MetadataDefinition definition, IndexingField field, String fieldName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Find the metadata to index from its path
      Parameters:
      content - the content currently being traversed.
      pathSegments - The segments of path of metadata to index
      metadata - The parent composite metadata
      definition - The metadata definition
      field - the current indexing field.
      fieldName - the name of the field to index.
      document - The main solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      additionalDocuments - The additional documents
    • findAndIndexMetadataField

      protected void findAndIndexMetadataField(Content content, String[] pathSegments, CompositeMetadata metadata, MetadataDefinition definition, IndexingField field, String fieldName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Find and index a metadata.
      Parameters:
      content - the current content being traversed.
      pathSegments - the full metadata path segments.
      metadata - the current metadata holder.
      definition - the current metadata definition.
      field - the current indexing field.
      fieldName - the name of the field to index.
      document - the solr main document.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      additionalDocuments - the solr additional documents.
    • findAndIndexOverridingField

      protected void findAndIndexOverridingField(Content content, IndexingModel indexingModel, CustomMetadataIndexingField field, String fieldName, MetadataDefinition definition, String[] pathSegments, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Find and index a property represented by an overriding field.
      Parameters:
      content - the current content being traversed.
      indexingModel - the current indexing model.
      pathSegments - the full metadata path segments.
      definition - the current metadata definition.
      field - the current indexing field.
      fieldName - the name of the field to index.
      document - the solr main document.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      additionalDocuments - the solr additional documents.
    • indexMetadata

      public void indexMetadata(Content content, String metadataName, CompositeMetadata metadata, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, List<org.apache.solr.common.SolrInputDocument> additionalDocuments, String fieldName, MetadataDefinition definition)
      Index a content metadata.
      Parameters:
      content - the current content being traversed.
      metadataName - The name of metadata to index
      metadata - The parent composite metadata
      document - the solr document to index into.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      additionalDocuments - The solr additional documents used for repeater instance
      fieldName - the name of the indexed field.
      definition - the metadata definition.
    • indexOverridingField

      public void indexOverridingField(CustomMetadataIndexingField field, Content content, String fieldName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Index a property represented by an overriding field.
      Parameters:
      field - The overriding field.
      content - The content of which to get the property.
      fieldName - The name of the field to index.
      document - the solr document to index into.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      additionalDocuments - The solr additional documents used for repeater instance
    • indexValues

      public void indexValues(Content content, String fieldName, MetadataType type, Object[] values, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc)
      Index values
      Parameters:
      content - The content being indexed.
      fieldName - The Solr field's name
      type - the type of values to index
      values - the values
      document - the Solr document
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
    • indexReferenceMetadata

      public void indexReferenceMetadata(CompositeMetadata metadata, String metadataName, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'reference' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexStringMetadata

      public void indexStringMetadata(CompositeMetadata metadata, String metadataName, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'string' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexMultilingualStringMetadata

      public void indexMultilingualStringMetadata(CompositeMetadata metadata, String metadataName, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, MetadataDefinition definition)
      Index a multilingual string metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      definition - The metadata definition
    • indexMultilingualStringValues

      public void indexMultilingualStringValues(MultilingualString value, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName)
      Index a multilingual string values
      Parameters:
      value - The multilingual string
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
    • indexMultilingualStringValues

      public void indexMultilingualStringValues(String[] values, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language)
      Index multilingual 'string' values
      Parameters:
      values - The values
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The language for values.
    • indexMultilingualStringValuesForSorting

      public void indexMultilingualStringValuesForSorting(String value, org.apache.solr.common.SolrInputDocument document, String fieldName, String language)
      Index multilingual 'string' value in sort field
      Parameters:
      value - The value
      document - The solr document to index into
      fieldName - The index field name
      language - The language
    • indexStringValues

      public void indexStringValues(String[] values, String contentId, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, boolean isFacetable)
      Index 'string' values
      Parameters:
      values - The values
      contentId - The content id. For logging purposes
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      isFacetable - true if the field can be used as a facet.
    • indexDateMetadata

      public void indexDateMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'date' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexDateValues

      public void indexDateValues(Date[] values, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index 'date' values
      Parameters:
      values - The values
      document - The solr document to index into
      fieldName - The index field name
    • indexDateTimeMetadata

      public void indexDateTimeMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'datetime' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexDateTimeValues

      public void indexDateTimeValues(Date[] values, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index 'datetime' values
      Parameters:
      values - The values
      document - The solr document to index into
      fieldName - The index field name
    • indexDoubleMetadata

      public void indexDoubleMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'double' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexDoubleValues

      public void indexDoubleValues(Double[] values, org.apache.solr.common.SolrInputDocument document, String fieldName, boolean isFacetable)
      Index 'double' values
      Parameters:
      values - The values
      document - The solr document to index into
      fieldName - The index field name
      isFacetable - true if the field can be used as a facet.
    • indexLongMetadata

      public void indexLongMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'long' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexLongValues

      public void indexLongValues(Long[] values, org.apache.solr.common.SolrInputDocument document, String fieldName, boolean isFacetable)
      Index 'long' values
      Parameters:
      values - The values
      document - The solr document to index into
      fieldName - The index field name
      isFacetable - true if the field can be used as a facet.
    • indexUserMetadata

      public void indexUserMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'user' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexUserValues

      public void indexUserValues(UserIdentity[] users, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language)
      Index 'user' values
      Parameters:
      users - The users
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
    • indexBooleanMetadata

      public void indexBooleanMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'boolean' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexBooleanValues

      public void indexBooleanValues(Boolean[] values, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index 'boolean' values
      Parameters:
      values - The values
      document - The solr document to index into
      fieldName - The index field name
    • indexRichtextMetadata

      public void indexRichtextMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'richtext' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexRichtextValue

      public void indexRichtextValue(RichText richText, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language)
      Index 'richtext' values
      Parameters:
      richText - The rich text to index.
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name.
      language - The content language.
    • _richTextToString

      Gets a XML as a string and extract the text only
      Parameters:
      is - The inputstream of XML
      Returns:
      The text or null if the XML is not well formed
    • indexBinaryMetadata

      public void indexBinaryMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'binary' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexFileMetadata

      public void indexFileMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'file' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexFileValue

      public void indexFileValue(Object[] values, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language)
      Index a 'file' metadata
      Parameters:
      values - The values.
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
    • indexFullTextBinary

      protected void indexFullTextBinary(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language, MetadataDefinition definition)
      Index a 'binary' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      contentDoc - The content document.
      fieldName - The index field name
      language - The content language.
      definition - The metadata definition
    • indexFullTextBinaryValue

      protected void indexFullTextBinaryValue(InputStream is, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, String language)
      Index a 'binary' value
      Parameters:
      is - An InputStream on the binary data.
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The index field name
      language - The content language.
    • indexContentMetadata

      public void indexContentMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'content' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexContentValues

      public void indexContentValues(String[] contentIds, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index content values.
      Parameters:
      contentIds - The ID of the contents to index.
      document - The solr document to index into.
      fieldName - the field name.
    • indexSubContentMetadata

      public void indexSubContentMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'sub_content' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexGeoCodeMetadata

      public void indexGeoCodeMetadata(CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, String fieldName, MetadataDefinition definition)
      Index a 'geocode' metadata
      Parameters:
      metadata - The parent composite metadata
      metadataName - The name of metadata to index
      document - The solr document to index into
      fieldName - The index field name
      definition - The metadata definition
    • indexGeocodeValue

      public void indexGeocodeValue(double latitude, double longitude, org.apache.solr.common.SolrInputDocument document, String fieldName)
      Index a 'geocode' metadata
      Parameters:
      latitude - the coord latitude.
      longitude - the coord longitude.
      document - The solr document to index into
      fieldName - The index field name
    • indexCompositeMetadata

      public void indexCompositeMetadata(Content content, CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, MetadataDefinition definition, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Index a composite metadata, i.e. browse and index the sub-metadatas.
      Parameters:
      content - The content being indexed.
      metadata - The parent metadata.
      metadataName - The composite metadata name.
      document - The solr document to index into.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The field name.
      definition - The composite metadata definition.
      additionalDocuments - The solr additional documents used for repeater instance
    • indexRepeaterMetadata

      public void indexRepeaterMetadata(Content content, CompositeMetadata metadata, String metadataName, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String fieldName, MetadataDefinition definition, List<org.apache.solr.common.SolrInputDocument> additionalDocuments)
      Index a repeater metadata, i.e. browse and index the entries.
      Parameters:
      content - The content being indexed.
      metadata - The parent metadata.
      metadataName - The repeater metadata name.
      document - The solr document to index into.
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      fieldName - The field name.
      definition - The repeater metadata definition.
      additionalDocuments - The solr additional documents used for repeater instance
    • indexResourceContent

      protected void indexResourceContent(Resource resource, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc, String language)
      Index the content of a resource.
      Parameters:
      resource - The resource
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      language - The content language.
    • indexResourceContentValue

      protected void indexResourceContentValue(InputStream is, String[] keywords, String description, String language, org.apache.solr.common.SolrInputDocument document, org.apache.solr.common.SolrInputDocument contentDoc) throws IOException, TikaException
      Index the content of a resource.
      Parameters:
      is - An input stream on the resource content.
      keywords - The resource keywords.
      description - The resource description.
      language - The content language.
      document - The solr document to index into
      contentDoc - The parent content document to index into (can be null if the main document is the content doc itself).
      Throws:
      TikaException - If an error occurs extracting the document's text content.
      IOException - If an error occurs reading the document's text content.
    • indexFulltextValue

      protected void indexFulltextValue(org.apache.solr.common.SolrInputDocument mainDocument, org.apache.solr.common.SolrInputDocument contentDoc, String text, String language)
      Index a full-text value.
      Parameters:
      mainDocument - The document being used, can be either the content document itself or a repeater document.
      contentDoc - The parent content document. If the mainDocument is the content document, this will be null.
      text - The text to index.
      language - The content language.
    • indexFulltextValue

      public static void indexFulltextValue(org.apache.solr.common.SolrInputDocument document, String text, String language)
      Index a full-text value.
      Parameters:
      document - The document to index into.
      text - The text to index.
      language - The content language.
    • indexFulltextValue

      public static void indexFulltextValue(org.apache.solr.common.SolrInputDocument document, String text, Collection<String> languages)
      Index a full-text value.
      Parameters:
      document - The document to index into.
      text - The text to index.
      languages - The languages.
    • indexLanguageFulltextValue

      protected static void indexLanguageFulltextValue(org.apache.solr.common.SolrInputDocument document, String text, String language)
      Index a full-text value in the language-specific fields.
      Parameters:
      document - The document to index into.
      text - The text to index.
      language - The content language.