我通过 Dataimporthandler 从 MySql 导入数据。这非常有效,我收到以下消息:
Indexing completed. Added/Updated: 2,172 documents. Deleted 0 documents. (Duration: 01s) Requests: 1 (1/s), Fetched: 2,172 (2,172/s), Skipped: 0, Processed: 2,172 (2,172/s)
但是当我查看概述时,它说:
Num Docs: 1470 Max Doc: 2172 Deleted Docs: 702
所以 702 个文档被删除了,原因我实在搞不明白。在我的架构中,我不使用任何唯一字段或可能会给重复带来麻烦的字段。
数据配置.xml
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="xxx"
user="xxx"
password="xxx"
/>
<document>
<entity name="product" query="CALL getSolrProducts();" transformer="RegexTransformer">
<field column="uuid" name="uuid"/>
<field column="id" name="id"/>
<field column="productimage" name="productimage"/>
<field column="producturl" name="producturl"/>
<field column="productpricenew" name="productpricenew"/>
<field column="productpriceold" name="productpriceold"/>
<field column="brandid" name="productbrand"/>
<field column="productbrandname" name="productbrandname"/>
<field column="productbrandurl" name="productbrandurl"/>
<field column="productbrandimage" name="productbrandimage"/>
<field column="productbranddata" name="productbranddata"/>
<field column="productshippingcoast" name="productshippingcoast"/>
<field column="productlink" name="productlink"/>
<field column="color" name="color" splitBy=","/>
<field column="colordata" name="colordata" splitBy=","/>
<field column="productdescription" name="productdescription"/>
<field column="upc" name="upc" splitBy=","/>
<field column="productname" name="productname"/>
<field column="productshop" name="productshop"/>
<field column="productshopname" name="productshopname"/>
<field column="productshopimage" name="productshopimage"/>
<field column="productimagethumb" name="productimagethumb"/>
<field column="productshopdata" name="productshopdata"/>
<field column="cat1id" name="cat1id"/>
<field column="cat2id" name="cat2id"/>
<field column="cat3id" name="cat3id"/>
<field column="cat4id" name="cat4id"/>
<field column="cat1data" name="cat1data"/>
<field column="cat2data" name="cat2data"/>
<field column="cat3data" name="cat3data"/>
<field column="cat4data" name="cat4data"/>
<field column="size" name="size" splitBy=","/>
<field column="sizedata" name="sizedata" splitBy=","/>
<field column="recommendations" name="recommendations" splitBy=","/>
</entity>
</document>
</dataConfig>
有人指点一下吗?
最佳答案
由于您选中了clean
,DIH 首先发出“删除全部”更新查询,然后开始发布新文档。索引完成后,DIH 会发出提交,该提交将仅保留发布的新文档并删除索引开始之前存在的所有旧文档。您的数据库一定已更新,因此您现在获得了更多文档,并且 702 个已删除的文档对应于索引开始之前索引中存在的文档。 (在DIH中检查optimize
将清除已删除的文档,但优化对于大型索引可能会很昂贵,并且删除的文档无论如何都不会显示在搜索结果中,因此可能没有太大好处。)
关于mysql - 为什么Solr导入后会删除文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25203414/