【问题标题】:Why does Solr delete documents after import为什么 Solr 导入后会删除文档
【发布时间】:2014-08-08 12:21:44
【问题描述】:

我通过 Dataimporthandler 从 MySql 导入数据。这很好用,我收到了这条消息:

索引已完成。添加/更新:2,172 个文档。已删除 0 文件。 (持续时间:01 秒)请求:1 (1/秒),获取:2,172 (2,172/s),跳过:0,处理:2,172 (2,172/s)

但是当我查看我的概览时,它会说:

文档数:1470 最大文档:2172 已删除文档: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>

有人指点吗?

【问题讨论】:

  • 我想到两件事:(1)数据导入处理程序是修改索引中数据的唯一途径吗?还是有其他改变索引数据的东西? (2) 您会发布部分数据配置吗?您可以在那里定义删除语句。
  • 是的,数据导入处理程序是修改此核心数据的唯一路由。
  • 谢谢,这看起来并不可疑。你是如何调用/开始数据导入的?你用clean=true了吗?
  • 现在我正在通过 Webinterface solr 提供它,但检查了 clean。我想这几乎是一样的。

标签: mysql solr solr4


【解决方案1】:

由于您检查了clean,DIH 首先发出“全部删除”更新查询,然后开始发布新文档。一旦索引完成,DIH 会发出一个提交,这将只保留发布的新文档并删除索引开始之前存在的所有旧文档。你的数据库一定已经更新了,所以你现在有更多的文档,702 个删除的文档对应于索引开始之前存在于索引中的文档。 (在 DIH 中检查 optimize 将清除已删除的文档,但优化对于大型索引可能代价高昂,并且已删除的文档无论如何都不会出现在搜索结果中,因此可能没有多大好处。)

【讨论】:

  • 是的,这就是我提出问题的地方。就是这样:)
  • 作为记录,请阅读in the Wiki: clean :(默认为'true')。告诉在索引开始之前是否清理索引。
  • @cheffe 哎呀,很抱歉偷走了你的答案和分数
  • 别担心,够了:)
猜你喜欢
  • 2018-11-28
  • 1970-01-01
  • 1970-01-01
  • 2016-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多