【问题标题】:forgiving solr indexing宽容的 solr 索引
【发布时间】:2013-01-07 14:38:46
【问题描述】:

solr 是否有可能以更可原谅的方式索引文档?

目前,如果我尝试索引不适合 100% 架构的数据,我总是会收到 SolrException。如果 solr 无论如何都可以索引文档并为不正确的字段打印异常,那就更好了。

【问题讨论】:

  • 恕我直言,您应该尝试修复索引过程...
  • 也许你最好使用无模式搜索,比如elasticsearch.org
  • @Mauricio Scheffer:你说得对,但我的数据基础很大,有时甚至有点不一致。所以我不能保证错误的数据是通过 solr 传递的。如果 solr 可以为我处理它会容易得多。
  • @Paul Dixon:谢谢你的想法,但由于政治原因我不能这样做

标签: solr


【解决方案1】:

如果您有权访问 solr 正在运行的服务器并且可以看到 solr 提供此信息的日志。您可以在架构中添加一个设置,该设置可以捕获下载中示例中可以找到的所有特定类型

catchall 字段,包含所有其他可搜索的文本字段(已实现 通过 copyField 在此架构中进一步

   <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/>

【讨论】:

  • 感谢您的回复,但我不明白这如何解决我的问题。万一出现错误,包罗万象的字段不会接管。在我的数据库中,我有一个应该只出现一次的字段,但在一些不一致的数据集中它定义了两次。所以我不想只忽略第二个值或忽略整个字段并索引文档。我可以轻松地将字段设置为多个,但我不喜欢这样。
  • 您最好的办法是查看日志,因为这将为您提供所需的信息。日志将告诉您哪个字段引发错误以及原因,即数据类型不匹配。
【解决方案2】:

稍微扩展@Si Philp 的回答。如果您查看 Solr 发行版附带的示例 schema.xml,您将看到以下条目:

<!-- uncomment the following to ignore any fields that don't already match an existing 
    field name or dynamic field, rather than reporting them as an error. 
    alternately, change the type="ignored" to some other type e.g. "text" if you want 
    unknown fields indexed and/or stored by default --> 
<!--dynamicField name="*" type="ignored" multiValued="true" /-->

<!-- since fields of this type are by default not stored or indexed,
     any data added to them will be ignored outright.  --> 
<fieldtype name="ignored" stored="false" indexed="false" multiValued="true"
  class="solr.StrField" />

这将在您的架构中为尚未定义的任何字段创建动态定义,它们将被忽略。但是,它不会为您提供任何被忽略的字段/值的指示符。

【讨论】:

  • 感谢您的回复。我的 schema.xml 中已经有了这个,但这并不能解决任何多值或错误的字段类型(字符串 -> 整数)类型的问题。
  • 我不知道 Solr 中有任何东西可以为您处理这些类型的错误。 Solr 不是数据验证工具,它假定您在加载数据之前正在处理这些类型的问题。在将数据提交给 Solr 以进行索引之前,您需要自己考虑这些类型的事情。
猜你喜欢
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-23
  • 1970-01-01
  • 2011-10-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多