Class AbstractSolrCoreInitializer

    • Field Detail

      • SOLR_FIELD_ID

        public static final String SOLR_FIELD_ID
        The name of the field containing the identifier of the document.
        See Also:
        Constant Field Values
      • SCHEMA_VERSION_12_3

        public static final long SCHEMA_VERSION_12_3
        The base schema version for XWiki 12.3.
        See Also:
        Constant Field Values
      • SCHEMA_VERSION_12_5

        public static final long SCHEMA_VERSION_12_5
        The base schema version for XWiki 12.5.
        Since:
        12.5RC1
        See Also:
        Constant Field Values
      • SCHEMA_VERSION_12_6

        public static final long SCHEMA_VERSION_12_6
        The base schema version for XWiki 12.6.
        Since:
        12.6
        See Also:
        Constant Field Values
      • SCHEMA_VERSION_12_10

        public static final long SCHEMA_VERSION_12_10
        The base schema version for XWiki 12.10.
        Since:
        12.10
        See Also:
        Constant Field Values
      • SCHEMA_VERSION_14_7

        public static final long SCHEMA_VERSION_14_7
        The base schema version for XWiki 14.7.
        Since:
        14.7RC1
        See Also:
        Constant Field Values
      • SCHEMA_BASE_VERSION

        public static final long SCHEMA_BASE_VERSION
        The base schema version.
        See Also:
        Constant Field Values
      • SOLR_FIELD_NAME

        protected static final String SOLR_FIELD_NAME
        The name of the attribute containing the name of the Solr field.
        See Also:
        Constant Field Values
      • SOLR_FIELD_INDEXED

        protected static final String SOLR_FIELD_INDEXED
        The name of the attribute indicating if the Solr field should be indexed.
        See Also:
        Constant Field Values
      • SOLR_FIELD_STORED

        protected static final String SOLR_FIELD_STORED
        The name of the attribute indicating if the Solr field should be stored.
        See Also:
        Constant Field Values
      • SOLR_FIELD_SORTMISSINGLAST

        protected static final String SOLR_FIELD_SORTMISSINGLAST
        The name of the attribute Control the placement of documents when a sort field is not present.
        See Also:
        Constant Field Values
      • SOLR_FIELD_MULTIVALUED

        protected static final String SOLR_FIELD_MULTIVALUED
        The name of the attribute indicating that a single document might contain multiple values for this Solr field type.
        See Also:
        Constant Field Values
      • SOLR_FIELD_DOCVALUES

        protected static final String SOLR_FIELD_DOCVALUES
        The name of the attribute indicating if the value of the field will be put in a column-oriented DocValues structure.
        See Also:
        Constant Field Values
      • descriptor

        @Inject
        protected org.xwiki.component.descriptor.ComponentDescriptor<SolrCoreInitializer> descriptor
      • solrSchemaUtils

        @Inject
        protected org.xwiki.search.solr.internal.SolrSchemaUtils solrSchemaUtils
      • client

        protected org.apache.solr.client.solrj.SolrClient client
      • types

        protected Map<String,​org.apache.solr.client.solrj.response.schema.FieldTypeRepresentation> types
    • Constructor Detail

      • AbstractSolrCoreInitializer

        public AbstractSolrCoreInitializer()
    • Method Detail

      • initialize

        public void initialize​(org.apache.solr.client.solrj.SolrClient client)
                        throws SolrException
        Description copied from interface: SolrCoreInitializer
        Initialize the client after its creation.
        Specified by:
        initialize in interface SolrCoreInitializer
        Parameters:
        client - to manipulate the core
        Throws:
        SolrException - when failing to initialize the core
      • getFieldTypes

        protected Map<String,​org.apache.solr.client.solrj.response.schema.FieldTypeRepresentation> getFieldTypes​(boolean force)
                                                                                                                throws SolrException
        Throws:
        SolrException
      • createSchema

        protected abstract void createSchema()
                                      throws SolrException
        Create the schema from scratch.
        Throws:
        SolrException - when failing to create the schema
      • migrateSchema

        protected abstract void migrateSchema​(long cversion)
                                       throws SolrException
        Migrate the existing schema.
        Parameters:
        cversion - the version of the schema currently stored
        Throws:
        SolrException - when failing to migrate the schema
      • getVersion

        protected abstract long getVersion()
        Returns:
        the version of this core's schema according to current specifications
      • getCurrentXWikiVersion

        protected Long getCurrentXWikiVersion()
                                       throws SolrException
        Returns:
        the version of the base schema currently stored in Solr
        Throws:
        SolrException - when failing to get the type
      • getCurrentCoreVersion

        protected Long getCurrentCoreVersion()
                                      throws SolrException
        Returns:
        the version of the schema as defined by this initializer currently stored in Solr
        Throws:
        SolrException - when failing to get the type
      • addStringField

        protected void addStringField​(String name,
                                      boolean multiValued,
                                      boolean dynamic)
                               throws SolrException
        Add a field in the Solr schema.

        A general text field that has reasonable, generic cross-language defaults: it tokenizes with StandardTokenizer, removes stop words from case-insensitive "stopwords.txt" (empty by default), and down cases. At query time only, it also applies synonyms.

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addTextGeneralField

        protected void addTextGeneralField​(String name,
                                           boolean multiValued,
                                           boolean dynamic)
                                    throws SolrException
        Add a field in the Solr schema.

        A general text field that has reasonable, generic cross-language defaults: it tokenizes with StandardTokenizer, removes stop words from case-insensitive "stopwords.txt" (empty by default), and down cases. At query time only, it also applies synonyms.

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
        Since:
        12.9RC1
      • addBooleanField

        protected void addBooleanField​(String name,
                                       boolean multiValued,
                                       boolean dynamic)
                                throws SolrException
        Add a field in the Solr schema.

        Contains either true or false. Values of "1", "t", or "T" in the first character are interpreted as true. Any other values in the first character are interpreted as false.

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addPIntField

        protected void addPIntField​(String name,
                                    boolean multiValued,
                                    boolean dynamic)
                             throws SolrException
        Add a field in the Solr schema.

        Integer field (32-bit signed integer).

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addPFloatField

        protected void addPFloatField​(String name,
                                      boolean multiValued,
                                      boolean dynamic)
                               throws SolrException
        Add a field in the Solr schema.

        Floating point field (32-bit IEEE floating point).

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addPLongField

        protected void addPLongField​(String name,
                                     boolean multiValued,
                                     boolean dynamic)
                              throws SolrException
        Add a field in the Solr schema.

        Long field (64-bit signed integer).

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addPDoubleField

        protected void addPDoubleField​(String name,
                                       boolean multiValued,
                                       boolean dynamic)
                                throws SolrException
        Add a field in the Solr schema.

        Double field (64-bit IEEE floating point).

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addPDateField

        protected void addPDateField​(String name,
                                     boolean multiValued,
                                     boolean dynamic)
                              throws SolrException
        Add a field in the Solr schema.

        Date field. Represents a point in time with millisecond precision.

        Parameters:
        name - the name of the field to add
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addBinaryField

        protected void addBinaryField​(String name,
                                      boolean dynamic)
                               throws SolrException
        Binary data.
        Parameters:
        name - the name of the field to add
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • addMapField

        protected void addMapField​(String name)
                            throws SolrException
        Binary data.
        Parameters:
        name - the name of the field to add
        Throws:
        SolrException - when failing to add the field
      • addField

        protected void addField​(String name,
                                String type,
                                boolean dynamic,
                                Object... attributes)
                         throws SolrException
        Add a field in the Solr schema.
        Parameters:
        name - the name of the field to add
        type - the tpe of the field to addd
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to add the field
      • addField

        protected void addField​(Map<String,​Object> fieldAttributes,
                                boolean dynamic)
                         throws SolrException
        Add a field in the Solr schema.
        Parameters:
        fieldAttributes - the attributes of the field to add
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
      • deleteField

        protected void deleteField​(String fieldName,
                                   boolean dynamic)
                            throws SolrException
        Delete a field in the Solr schema.
        Parameters:
        fieldName - the name of the field to delete.
        dynamic - true if the field to delete is dynamic.
        Throws:
        SolrException - when failing to delete the field.
        Since:
        12.9RC1
      • setStringField

        protected void setStringField​(String name,
                                      boolean multiValued,
                                      boolean dynamic,
                                      Object... attributes)
                               throws SolrException
        Add or replace a field in the Solr schema.

        String (UTF-8 encoded string or Unicode). Strings are intended for small fields and are not tokenized or analyzed in any way. They have a hard limit of slightly less than 32K.

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setTextGeneralField

        protected void setTextGeneralField​(String name,
                                           boolean multiValued,
                                           boolean dynamic,
                                           Object... attributes)
                                    throws SolrException
        Add or replace a field in the Solr schema.

        A general text field that has reasonable, generic cross-language defaults: it tokenizes with StandardTokenizer, removes stop words from case-insensitive "stopwords.txt" (empty by default), and down cases. At query time only, it also applies synonyms.

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.10
      • setBooleanField

        protected void setBooleanField​(String name,
                                       boolean multiValued,
                                       boolean dynamic,
                                       Object... attributes)
                                throws SolrException
        Add or replace a field in the Solr schema.

        Contains either true or false. Values of "1", "t", or "T" in the first character are interpreted as true. Any other values in the first character are interpreted as false.

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setPIntField

        protected void setPIntField​(String name,
                                    boolean multiValued,
                                    boolean dynamic,
                                    Object... attributes)
                             throws SolrException
        Add or replace a field in the Solr schema.

        Integer field (32-bit signed integer).

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setPFloatField

        protected void setPFloatField​(String name,
                                      boolean multiValued,
                                      boolean dynamic,
                                      Object... attributes)
                               throws SolrException
        Add or replace a field in the Solr schema.

        Floating point field (32-bit IEEE floating point).

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setPLongField

        protected void setPLongField​(String name,
                                     boolean multiValued,
                                     boolean dynamic,
                                     Object... attributes)
                              throws SolrException
        Add or replace a field in the Solr schema.

        Long field (64-bit signed integer).

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setPDoubleField

        protected void setPDoubleField​(String name,
                                       boolean multiValued,
                                       boolean dynamic,
                                       Object... attributes)
                                throws SolrException
        Add or replace a field in the Solr schema.

        Double field (64-bit IEEE floating point).

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setPDateField

        protected void setPDateField​(String name,
                                     boolean multiValued,
                                     boolean dynamic,
                                     Object... attributes)
                              throws SolrException
        Add or replace a field in the Solr schema.

        Date field. Represents a point in time with millisecond precision.

        Parameters:
        name - the name of the field to set
        multiValued - true if the field can contain several values
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setBinaryField

        protected void setBinaryField​(String name,
                                      boolean dynamic,
                                      Object... attributes)
                               throws SolrException
        Add or replace a field in the Solr schema.

        Binary data.

        Parameters:
        name - the name of the field to set
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setMapField

        protected void setMapField​(String name,
                                   Object... attributes)
                            throws SolrException
        Add or replace a field in the Solr schema.

        Map data.

        Parameters:
        name - the name of the field to set
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to set the field
        Since:
        12.5RC1
      • setField

        protected void setField​(String name,
                                String type,
                                boolean dynamic,
                                Object... attributes)
                         throws SolrException
        Add or replace a field in the Solr schema.
        Parameters:
        name - the name of the field to set
        type - the type of the field to set
        dynamic - true to create a dynamic field
        attributes - attributed to add to the field definition
        Throws:
        SolrException - when failing to add the field
        Since:
        12.5RC1
      • setField

        protected void setField​(Map<String,​Object> fieldAttributes,
                                boolean dynamic)
                         throws SolrException
        Add or replace a field in the Solr schema.
        Parameters:
        fieldAttributes - the attributes of the field to add
        dynamic - true to create a dynamic field
        Throws:
        SolrException - when failing to add the field
        Since:
        12.5RC1
      • addCopyField

        protected void addCopyField​(String source,
                                    String... dest)
                             throws SolrException
        Add a copy field.
        Parameters:
        source - the source field name
        dest - the collection of the destination field names
        Throws:
        SolrException - when failing to add the field
        Since:
        13.3RC1
      • addFieldType

        protected void addFieldType​(String name,
                                    String solrClass,
                                    Object... attributes)
                             throws SolrException
        Add a field type in the Solr schema.
        Parameters:
        name - the name of the field type
        solrClass - the class of the field type
        attributes - the other attributes of the field type
        Throws:
        SolrException - when failing to add the field
      • replaceFieldType

        protected void replaceFieldType​(String name,
                                        String solrClass,
                                        Object... attributes)
                                 throws SolrException
        Replace a field type in the Solr schema.
        Parameters:
        name - the name of the field type
        solrClass - the class of the field type
        attributes - the other attributes of the field type
        Throws:
        SolrException - when failing to add the field
      • setFieldType

        protected void setFieldType​(String name,
                                    String solrClass,
                                    boolean add,
                                    Object... attributes)
                             throws SolrException
        Add a field type in the Solr schema.
        Parameters:
        name - the name of the field type
        solrClass - the class of the field type
        add - true if the field type should be added, false for replace
        attributes - the other attributes of the field type
        Throws:
        SolrException - when failing to add the field
      • setFieldType

        protected void setFieldType​(Map<String,​Object> attributes,
                                    boolean add)
                             throws SolrException
        Add a field type in the Solr schema.
        Parameters:
        attributes - the attributes of the field to add
        add - true if the field type should be added, false for replace
        Throws:
        SolrException - when failing to add the field
      • setFieldType

        protected void setFieldType​(org.apache.solr.client.solrj.request.schema.FieldTypeDefinition definition,
                                    boolean add)
                             throws SolrException
        Add a field type in the Solr schema.
        Parameters:
        definition - the definition of the field to add
        add - true if the field type should be added, false for replace
        Throws:
        SolrException - when failing to add the field
        Since:
        12.10
      • commit

        protected void commit()
                       throws SolrException
        Performs an explicit commit, causing pending documents to be committed for indexing.
        Throws:
        SolrException - when failing to commit