Class AbstractSolrCoreInitializer
- java.lang.Object
-
- org.xwiki.search.solr.AbstractSolrCoreInitializer
-
- All Implemented Interfaces:
SolrCoreInitializer
public abstract class AbstractSolrCoreInitializer extends Object implements SolrCoreInitializer
Base helper class to implementSolrCoreInitializer
.- Since:
- 12.3RC1
- Version:
- $Id: 273157533a0ed473944bc1a1b6dd7739dd5409f3 $
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.solr.client.solrj.SolrClient
client
protected org.xwiki.component.descriptor.ComponentDescriptor<SolrCoreInitializer>
descriptor
protected Map<String,Map<String,Object>>
fields
static long
SCHEMA_BASE_VERSION
The base schema version.static long
SCHEMA_VERSION_12_10
The base schema version for XWiki 12.10.static long
SCHEMA_VERSION_12_3
The base schema version for XWiki 12.3.static long
SCHEMA_VERSION_12_5
The base schema version for XWiki 12.5.static long
SCHEMA_VERSION_12_6
The base schema version for XWiki 12.6.static long
SCHEMA_VERSION_14_7
The base schema version for XWiki 14.7.protected static 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.static String
SOLR_FIELD_ID
The name of the field containing the identifier of the document.protected static String
SOLR_FIELD_INDEXED
The name of the attribute indicating if the Solr field should be indexed.protected static String
SOLR_FIELD_MULTIVALUED
The name of the attribute indicating that a single document might contain multiple values for this Solr field type.protected static String
SOLR_FIELD_NAME
The name of the attribute containing the name of the Solr field.protected static String
SOLR_FIELD_SORTMISSINGLAST
The name of the attribute Control the placement of documents when a sort field is not present.protected static String
SOLR_FIELD_STORED
The name of the attribute indicating if the Solr field should be stored.protected org.xwiki.search.solr.internal.SolrSchemaUtils
solrSchemaUtils
protected Map<String,org.apache.solr.client.solrj.response.schema.FieldTypeRepresentation>
types
-
Constructor Summary
Constructors Constructor Description AbstractSolrCoreInitializer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addBinaryField(String name, boolean dynamic)
Binary data.protected void
addBooleanField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addCopyField(String source, String... dest)
Add a copy field.protected void
addField(String name, String type, boolean dynamic, Object... attributes)
Add a field in the Solr schema.protected void
addField(Map<String,Object> fieldAttributes, boolean dynamic)
Add a field in the Solr schema.protected void
addFieldType(String name, String solrClass, Object... attributes)
Add a field type in the Solr schema.protected void
addMapField(String name)
Binary data.protected void
addPDateField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addPDoubleField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addPFloatField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addPIntField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addPLongField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addStringField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
addTextGeneralField(String name, boolean multiValued, boolean dynamic)
Add a field in the Solr schema.protected void
commit()
Performs an explicit commit, causing pending documents to be committed for indexing.protected abstract void
createSchema()
Create the schema from scratch.protected void
deleteField(String fieldName, boolean dynamic)
Delete a field in the Solr schema.String
getCoreName()
protected Long
getCurrentCoreVersion()
protected Long
getCurrentXWikiVersion()
protected Map<String,Map<String,Object>>
getFields(boolean force)
protected Map<String,org.apache.solr.client.solrj.response.schema.FieldTypeRepresentation>
getFieldTypes(boolean force)
protected abstract long
getVersion()
void
initialize(org.apache.solr.client.solrj.SolrClient client)
Initialize the client after its creation.protected void
initializeBaseSchema()
protected void
initializeCoreSchema()
protected abstract void
migrateSchema(long cversion)
Migrate the existing schema.protected void
replaceFieldType(String name, String solrClass, Object... attributes)
Replace a field type in the Solr schema.protected void
setBinaryField(String name, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setBooleanField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setCurrentCoreVersion(boolean add)
protected void
setCurrentXWikiVersion(boolean add)
protected void
setField(String name, String type, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setField(Map<String,Object> fieldAttributes, boolean dynamic)
Add or replace a field in the Solr schema.protected void
setFieldType(String name, String solrClass, boolean add, Object... attributes)
Add a field type in the Solr schema.protected void
setFieldType(Map<String,Object> attributes, boolean add)
Add a field type in the Solr schema.protected void
setFieldType(org.apache.solr.client.solrj.request.schema.FieldTypeDefinition definition, boolean add)
Add a field type in the Solr schema.protected void
setMapField(String name, Object... attributes)
Add or replace a field in the Solr schema.protected void
setPDateField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setPDoubleField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setPFloatField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setPIntField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setPLongField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setStringField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.protected void
setTextGeneralField(String name, boolean multiValued, boolean dynamic, Object... attributes)
Add or replace a field in the Solr schema.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.xwiki.search.solr.SolrCoreInitializer
isCache
-
-
-
-
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
-
-
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 interfaceSolrCoreInitializer
- 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
-
getFields
protected Map<String,Map<String,Object>> getFields(boolean force) throws SolrException
- Throws:
SolrException
-
initializeBaseSchema
protected void initializeBaseSchema() throws SolrException
- Throws:
SolrException
-
initializeCoreSchema
protected void initializeCoreSchema() 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
-
getCoreName
public String getCoreName()
- Specified by:
getCoreName
in interfaceSolrCoreInitializer
- Returns:
- the name of Solr core to initialize.
-
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
-
setCurrentXWikiVersion
protected void setCurrentXWikiVersion(boolean add) throws SolrException
- Throws:
SolrException
-
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
-
setCurrentCoreVersion
protected void setCurrentCoreVersion(boolean add) throws SolrException
- Throws:
SolrException
-
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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 addmultiValued
- true if the field can contain several valuesdynamic
- 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 adddynamic
- 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 addtype
- the tpe of the field to addddynamic
- true to create a dynamic fieldattributes
- 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 adddynamic
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setmultiValued
- true if the field can contain several valuesdynamic
- true to create a dynamic fieldattributes
- 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 setdynamic
- true to create a dynamic fieldattributes
- 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 setattributes
- 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 settype
- the type of the field to setdynamic
- true to create a dynamic fieldattributes
- 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 adddynamic
- 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 namedest
- 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 typesolrClass
- the class of the field typeattributes
- 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 typesolrClass
- the class of the field typeattributes
- 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 typesolrClass
- the class of the field typeadd
- true if the field type should be added, false for replaceattributes
- 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 addadd
- 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 addadd
- 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
-
-