problem
SolrWriter Error creating document: SolrInputDocument (fields) does not correspond to field-related values
At first, I changed the database field type
field to use tinyint type, only to find that this type is not in Solr
! ! ! As shown above, the data types supported by Solr! ! !
There are some data types similar to text_ * prefixed at the back, all of which are the default word breaker types (such as the downloaded IK Chinese word breaker), which is not emphasized here! !
Two solutions
Add parameters after url
& serverTimezone = UTC & tinyInt1isBit = false
Be careful to escape the & symbol ...
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/nsi_database?useSSL=false&serverTimezone=UTC&tinyInt1isBit=false"
user="root"
password="123456"/>
<document>
<entity name="nsi_post_category_item" query="SELECT * FROM `nsi_post_category_item` WHERE is_check = 1">
<field column="item_id" name="itemId"/>
<field column="title" name="title"/>
<field column="summary_desc" name="summaryDesc"/>
<field column="content" name="content"/>
<field column="post_type" name="postType"/>
<field column="post_icon" name="postIcon"/>
<field column="comment_num" name="commentNum"/>
<field column="share_num" name="shareNum"/>
<field column="watch_num" name="watchNum"/>
<field column="collect_num" name="collectNum"/>
<field column="tag" name="tag"/>
<field column="open_id" name="openId"/>
<field column="avatar" name="avatar"/>
<field column="nick_name" name="nickName"/>
<field column="is_check" name="isCheck"/>
</entity>
</document>
</dataConfig>
analysis:
- The default parameter of tinyInt1isBit is true, and the storage length of tinyint type of Mysql is 1, Solr will convert the type of this field to Boolean type
- Set to false to convert tinyint data to Integer type, which corresponds to the pint type in Solr, so that it can be imported into the Solr index library
- Avoid tinyint field type storage number format length is 1, tinyint (1) will also be converted to True / False by default in Java
- The tinyInt1isBit parameter is case-sensitive when used
Do not use tinyint
Do not use tinyint instead use int type
- Modify your core's conf / managed-schema.xml configuration file
- Correspond to the mysql attribute and the field type in Solr
- varchar corresponds to string, and can also correspond to the type of tokenizer text_ik
- pint or plong corresponding to int
last step
Restart Solr and check Logging
The position of the red line usually prints an error log, or some abnormal information when synchronizing data
Reload it
When you change the configuration file, or modify the data type or field name to be synchronized in Mysql, or add new data to the index library, remember that Reload can solve many problems.
Pay attention to when there are multiple Cores. Choose the Core you want to change