【问题标题】:How to remove the big blank space in "str" tag in the XML response generated by Apache Solr ?如何删除 Apache Solr 生成的 XML 响应中“str”标签中的大空格?
【发布时间】:2014-01-08 16:27:17
【问题描述】:

我曾经使用以下 url 上传和索引 Word 文档..

java -Durl=http://localhost:8983/solr/update/extract?literal.id=1 -Dtype=application/word -jar post.jar document_name.doc

当我查询 Solr 索引时,它返回 XML 为 ..

  http://localhost:8983/solr/collection1/select?q=microfost&wt=xml&indent=true

回复是:

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="indent">true</str>
<str name="q">microfost</str>
<str name="_">1389196238897</str>
<str name="wt">xml</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="id">1</str>
<date name="last_modified">1601-01-01T00:00:00Z</date>
<str name="author">fazlan </str>
<str name="author_s">fazlan </str>
<arr name="content_type">
<str>application/msword</str>
</arr>
<arr name="content">

<str>  <-- problemtic tag with blank space -->

























This is a MSWord document. Microfost.

</str>
</arr>
<long name="_version_">1456677821213573120</long></doc>
</result>
</response>

现在我的问题是,&lt;arr name="content" &gt; 下标记为 的&lt;str&gt; 标记总是返回这个&lt;str&gt;,并带有大量空格,后面跟着内容.. 如何摆脱这个..

(我知道使用 java / jquery 删除 ..但我想从 xml 级别找到解决方案,无需任何后处理)

.

【问题讨论】:

    标签: xml solr lucene


    【解决方案1】:

    Tika 正在从 doc 文档中提取文本,它不会修改此类内容。 solr 返回的值是存储的值,所以你必须在它们被索引之前修改这些内容。

    您可以使用UpdateRequestProcessor 获取“内容”字段,并对其进行修剪,然后他们让它通过。我怀疑这会起作用,因为更新处理器会在提取完成后启动。

    【讨论】:

      猜你喜欢
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 2013-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多