如何将xml文档发布到solr中?

时间:2015-01-08 22:40:32

标签: xml 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中查询它。

在运行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。有什么我需要包装它来让它提交吗?

1 个答案:

答案 0 :(得分:3)

根据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>