当前位置: 移动技术网 > IT编程>数据库>Mysql > linux环境下解决solr7.4服务器多表导入数据覆盖的问题

linux环境下解决solr7.4服务器多表导入数据覆盖的问题

2020年10月10日  | 移动技术网IT编程  | 我要评论
问题溯源(导致solr数据覆盖可能原因):因为是多表的原因,可能在将mysql数据库导入到solr索引库中会出现不同数据相同id,而在solr实例schema配置会将id作为solr索引库的主键id,这样因为id的相同会导致不同的数据覆盖,丢失数据解决方法(不是唯一):1.在solrhome实例schema配置中添加<fieldType name="uuid" class="solr.UUIDField" indexed="true"/> <field name="uuid" t

问题溯源(导致solr数据覆盖可能原因):

因为是多表的原因,可能在将mysql数据库导入到solr索引库中会出现不同数据相同id,而在solr实例schema配置会将id作为solr索引库的主键id,这样因为id的相同会导致不同的数据覆盖,丢失数据

解决方法(不是唯一):

1.在solrhome实例schema配置中添加

<fieldType name="uuid" class="solr.UUIDField" indexed="true"/> 
<field name="uuid" type="uuid" indexed="true" stored="true" required="true"/>

2.在solrhome实例schema配置中修改

<uniqueKey>uuid</uniqueKey>(uuid原本为id)
<field name="_root_" type="uuid" docValues="false" indexed="true" stored="false"/>(type属性默认为string,要与主键id属性保持一致)

3.在solrconfig.xml文件中添加

<requestHandler name="/dataimport" class="solr.DataImportHandler">
    <lst name="defaults">
      <str name="config">data-config.xml</str>
      <str name="update.chain">uuid</str>(新添加的)
    </lst>
  </requestHandler>

再添加

<updateRequestProcessorChain name="uuid">
    <processor class="solr.UUIDUpdateProcessorFactory">
        <str name="fieldName">uuid</str>
    </processor>
    <processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>

最后重启solr服务器,数据重新导入

本文地址:https://blog.csdn.net/qq_42862907/article/details/109001905

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网