【问题标题】:How does SOLR Cell add document content?SOLR Cell 如何添加文档内容?
【发布时间】:2017-03-13 17:57:15
【问题描述】:

SOLR 有一个名为 Cell 的模块。它使用 Tika 从文档中提取内容并使用 SOLR 对其进行索引。

https://github.com/apache/lucene-solr/tree/master/solr/contrib/extraction 的来源中,我得出结论,Cell 将提取的原始文本文档文本放入名为“内容”的字段中。该字段由 SOLR 索引,但不存储。当您查询文档时,“内容”不会出现。

我的 SOLR 实例没有架构(我保留了默认架构)。

我正在尝试使用默认的UpdateRequestHandler(POST 到/solr/corename/update)来实现类似的行为。 POST 请求如下:

<add commitWithin="60000">
    <doc>
        <field name="content">lorem ipsum</field>
        <field name="id">123456</field>
        <field name="someotherfield_i">17</field>
    </doc>
</add>

使用以这种方式添加的文档,content 字段被索引并存储。它出现在查询结果中。我不想这样;太浪费空间了。

关于 Cell 添加文档的方式我缺少什么?

【问题讨论】:

    标签: solr solr-cell


    【解决方案1】:

    如果您不希望您的字段存储内容,则必须将字段设置为 stored="false"。

    由于您使用的是无模式模式(仍有模式,只是在添加新字段时动态生成),您必须使用Schema API 来更改字段。

    你可以do this by issuing a replace-field command:

    curl -X POST -H 'Content-type:application/json' --data-binary '{
      "replace-field":{
      "name":"content",
      "type":"text",
      "stored":false }
    }' http://localhost:8983/solr/collection/schema
    

    您可以通过向/collection/schema/fields 发出请求来see the defined fields

    【讨论】:

    • 我已经完成了查询。 content 字段在那里,但它没有 stored=false。还有一个名为_text_ 的字段确实有stored=false。但是,我在单元格来源中找不到对 _text_ 的任何引用...
    【解决方案2】:

    Cell 代码确实将内容作为content 添加到文档中,但是有一个内置的字段翻译规则将content 替换为_text_。在无模式 SOLR 中,_text_ 被标记为不用于存储。

    该规则由SolrContentHandler.addField() 中的以下行调用:

    String name = findMappedName(fname);
    

    在 params 对象中,有一条规则,fmap.content 应该被视为_text_。它来自corename\conf\solrconfig.xml,默认情况下有以下片段:

    <requestHandler name="/update/extract"
                  startup="lazy"
                  class="solr.extraction.ExtractingRequestHandler" >
      <lst name="defaults">
        <str name="lowernames">true</str>
        <str name="fmap.meta">ignored_</str>
        <str name="fmap.content">_text_</str> <!-- This one! -->
      </lst>
    </requestHandler>
    

    同时,在 corename\conf\managed_schema 中有一行:

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

    这就是整个故事。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多