Class SchemaHelper

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.solr.schema.SchemaHelper
All Implemented Interfaces:
LogEnabled, Component, Serviceable

public class SchemaHelper extends AbstractLogEnabled implements Component, Serviceable
Component providing helper methods to work with search schema and fields.
  • Field Details

  • Constructor Details

  • Method Details

    • service

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

      public static String getSchemaType(MetadataType metaType)
      Get the solr schema type from the metadata type.
      Parameters:
      metaType - The metadata type.
      Returns:
      The solr schema type.
    • isNameValid

      public static boolean isNameValid(String fieldName)
      Chekcs that the passed Solr field name is valid
      Parameters:
      fieldName - the Solr field name
      Returns:
      true if name is valid, false otherwise
    • getSchema

      public org.apache.solr.client.solrj.response.schema.SchemaRepresentation getSchema(String location)
      Get the schema at the corresponding location (source URI).
      Parameters:
      location - The location, as a source URI.
      Returns:
      The schema representation.
    • readSchema

      public org.apache.solr.client.solrj.response.schema.SchemaRepresentation readSchema(InputStream is) throws IOException, SAXException
      Read the static schema.
      Parameters:
      is - An input stream on the schema XML.
      Returns:
      The representation of the schema.
      Throws:
      IOException - If an error occurs reading the stream.
      SAXException - If an error occurs parsing the XML.
    • getFieldTypes

      protected List<org.apache.solr.client.solrj.request.schema.FieldTypeDefinition> getFieldTypes(NodeList fieldTypeNodes)
      Get the field type definitions from the corresponding DOM nodes.
      Parameters:
      fieldTypeNodes - The field type nodes.
      Returns:
      The list of field type definitions.
    • getFieldType

      protected org.apache.solr.client.solrj.request.schema.FieldTypeDefinition getFieldType(Node fieldTypeNode)
      Get a field type definition from the corresponding DOM node.
      Parameters:
      fieldTypeNode - The field type DOM node.
      Returns:
      The field type definition.
    • getAnalyzer

      protected org.apache.solr.client.solrj.request.schema.AnalyzerDefinition getAnalyzer(Node analyzerNode)
      Get an analyzer definition from the corresponding DOM node.
      Parameters:
      analyzerNode - The analyzer node.
      Returns:
      The analyzer definition.
    • getAttributes

      protected Map<String,Object> getAttributes(Node node)
      Extract a DOM node attributes as a Map.
      Parameters:
      node - The node.
      Returns:
      The attributes as a Map.
    • getList

      protected List<Map<String,Object>> getList(NodeList nodeList)
      Extract the list of DOM node attributes.
      Parameters:
      nodeList - The node list.
      Returns:
      A List of the attribute values as Maps.
    • filterListNode

      protected List<Map<String,Object>> filterListNode(List<Map<String,Object>> fieldList)
      Filters the list of field declarations and only keep valid ones.
      Parameters:
      fieldList - The list of fields to filter
      Returns:
      The filtered list