简体   繁体   中英

How do I POST an xml document into solr?

I'm using resteasy to send stuff to a solr instance running locally.

In the REST client, I do:

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

Headers: Content-Type: application

Body:

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

I get a 200OK It goes thru fine, and I can query for it in Solr Admin via the : query.

In the terminal window running solr, I see

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.

However, when I do this via xml:

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

I get a 200OK. But the terminal shows just:

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

but no commits, and I don't see it in Solr Admin. I'm working with something that spews out only XML, and I'm trying to push that into solr. Is there something I need to wrap it with to get it to commit?

according to the documentation the xml should have this format:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM