Record of problems encountered when using Solr
Solr page creation core
- Error message:
Error CREATEing SolrCore 'new_core': Unable to create core [new_core] Caused by: Multiple [schema.xml] fieldType registered to the same name: text_ik ignoring: text_ik{class=org.apache.solr.schema.TextField, analyzer=org.apache.solr.analysis.TokenizerChain,args=null}
- Cause Analysis:
This error indicates that there is a conflict when creating a new Solr core because there are multiple fieldTypes named
text_ik
registered inschema.xml or managed-schema
, where One is defined by theorg.apache.solr.schema.TextField
that comes with Solr. This causes conflicts, preventing new cores from being created.Simply put, it is configured twice when configuring the
ik
tokenizer.
- Solution:
If you have a custom
text_ik
fieldType definition in yourschema.xml or managed-schema
, and it matches Solr’s ownorg.apache.solr.schema The definition of .TextField
is duplicated. You can choose to delete the custom definition, or rename it to a name that does not conflict with the definition that comes with Solr, such astext_ik_custom
.Delete redundant
ik
tokenizer configuration.
- Error message:
Error CREATEing SolrCore 'new_core': Unable to create core [new_core] Caused by: [schema.xml] Duplicate field definition for 'id' [[[id{type=string,properties=indexed,stored,omitNorms,omitTermFreqAndPositions,sortMissingLast, required, useDocValuesAsStored, uninvertible, required=true}]]] and [[[id{type=string, properties=indexed, stored, omitNorms, omitTermFreqAndPositions, sortMissingLast, required, useDocValuesAsStored, uninvertible, required=true}]]]
- Cause Analysis:
This error means that when creating a new Solr core, there is a duplicate field definition
id
, andis defined multiple times in the
field. This causes conflicts, preventing new cores from being created.schema.xml or managed-schema
file id
- Solution:
Remove duplicate field definitions, make sure each field name is only defined once in
schema.xml or managed-schema
.
Relying on tika-app
error reporting in SpringBoot
- Error dependency:
<dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-app</artifactId> <version>2.8.0</version> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency>
- Error message:
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file: /D :/software/work/dataRepository/MavenRepository_bladx/org/apache/tika/tika-app/1.7/tika-app-1.7.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application -packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory
Cause Analysis:
It is caused by the conflict of the log library. The error message says that Logback and Log4jLoggerFactory conflict.
There is a log bean of its own in this dependency, and
slf4j
is relied on in the project, resulting in a conflict.
- Solution:
Modify the dependency to:
<dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-core</artifactId> <version>2.8.0</version> </dependency> <dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-parsers-standard-package</artifactId> <version>2.8.0</version> </dependency>
Call solrClient.addBeans(docs) in SpringBoot;
report error
- Error message:
org.apache.solr.client.solrj.beans.BindingException: class: class org.springblade.customer.entity.KnowledgeIk does not define any fields.
Cause Analysis:
It is because when using the data binding function of SolrJ, the fields defined in the corresponding Java class
org.springblade.customer.entity.KnowledgeIk
are inschema.xml or managed-schema
file is not defined.Fields in Solr must be defined before use.
Solution:
Add the
@Field
annotation to the attribute field. After adding this annotation, you usually don’t need to add it inmanaged-schema
(orschema.xml
in the old version) ) to explicitly define fields. The SolrJ library will automatically map the properties of the Java Bean to the fields in the Solr document according to the information of the@Field
annotation, and dynamically create the corresponding Field definitions. (The premise is that the attribute field format of the Java Bean can match the fields defined in the dynamic field in themanaged-schema
file, for example:*_s
is defined in the file field, and the attribute field you defined is namedxxx_s
.)Explicitly define fields in
managed-schema
(orschema.xml
in older versions).Note:
This dynamic field mapping method needs to ensure that Solr’s
managed-schema
file has corresponding permissions, allowing the SolrJ library to perform dynamic field creation. If your environment restricts the permission to automatically create fields, you need to manually define fields inmanaged-schema
.
The @Field annotation is added to the java attribute, but it is not displayed in Solr
Cause Analysis
No property name specified in the
@Field
annotation: By default, the@Field
annotation takes the property name of the Java object as the field name. However, if you want to use a different field name in Solr, you need to specify the field name using thename
attribute in the@Field
annotation. @Field(name = "custom_field_name") private String propertyName;
Attribute Values Are Null or Empty: If attributes have null or empty values, Solr will not add them to the document by default. Make sure the value of the attribute is not empty, so that it can be correctly mapped to the Solr document.
Documents not added to Solr: Attributes defined in
@Field
annotations are mapped to Solr documents only when the Java object is added to the Solr index. Make sure you’ve performed adding the Java object to the Solr index.Ignore field: The
ignore
attribute in the@Field
annotation can be used to specify whether to ignore a field. If a property is set to ignore, it will not be added to the Solr document. @Field(ignore = true) private String ignoredProperty;
- Field Type Mismatch: Solr requires the field type to match the property’s data type. Solr may refuse to add attributes to documents if the types do not match. Make sure you specify the field type correctly in the
@Field
annotation.