我如何 POST 一个 xml 文档到 solr 中?

How do I POST an xml document into solr?

我正在使用 resteasy 将内容发送到本地运行的 solr 实例。

在 REST 客户端中,我这样做:

URL: http://IPAddress:8983/solr/update?commitWithin=500

Headers: Content-Type: application

正文:

[
{
   "id" : "12345678",
  "fileName" : "scr.sh",
  "content" : "cd /opt/solr; echo hi"
}
]

我得到一个 200OK 它运行良好,我可以通过 : 查询在 Solr Admin 中查询它。

在终端window运行solr,我看到

5022136 [qtp1614114480-18] INFO  org.apache.solr.update.processor.LogUpdateProcessor  – [collection1] webapp=/solr path=/update params={commitWithin=500} {add=[12345678459 (1489768701904289792)]} 0 2
5022637 [commitScheduler-9-thread-1] INFO  org.apache.solr.update.UpdateHandler  – start commit{,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommit=true,prepareCommit=false}
5022649 [commitScheduler-9-thread-1] INFO  org.apache.solr.search.SolrIndexSearcher  – Opening Searcher@462cd2d6[collection1] main
5022650 [commitScheduler-9-thread-1] INFO  org.apache.solr.update.UpdateHandler  – end_commit_flush
5022651 [searcherExecutor-6-thread-1] INFO  org.apache.solr.core.SolrCore  – QuerySenderListener sending requests to Searcher@462cd2d6[collection1] main{StandardDirectoryReader(segments_1:9:nrt _0(4.10.3):C2/1:delGen=1 _1(4.10.3):C1 _2(4.10.3):C1 _3(4.10.3):C1)}
5022651 [searcherExecutor-6-thread-1] INFO  org.apache.solr.core.SolrCore  – QuerySenderListener done.

但是,当我通过 xml 执行此操作时:

<step> 
  <id>123456789112</id> 
  <fileName>deploy345.sh</fileName> 
  <content>cd /opt/el; echo $[/myServer/SidsProperty]</content>
</step>

我得到了 200OK。但是终端只显示:

5014515 [qtp1614114480-18] INFO  org.apache.solr.update.processor.LogUpdateProcessor  – [collection1] webapp=/solr path=/update params={commitWithin=500} {} 0 0

但没有提交,我在 Solr Admin 中也没有看到它。我正在处理只输出 XML 的东西,我正试图将其推送到 solr 中。我需要用什么东西来包装它才能提交吗?

根据 documentation,xml 应具有以下格式:

<add>
  <doc>
    <field name="id">123456789112</field>
    <field name="filename">deploy345.sh</field>
    <field name="content">cd /opt/el; echo $[/myServer/SidsProperty]</field>
  </doc>
</add>