Reputation: 10913
I'm new to solr and I'm trying to index the books.json
file inside the exampledocs directory using post.sh
:
But what I get is this:
Here's the books.json
file:
[
{
"id" : "978-0641723445",
"cat" : ["book","hardcover"],
"name" : "The Lightning Thief",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 12.50,
"pages_i" : 384
}
,
{
"id" : "978-1423103349",
"cat" : ["book","paperback"],
"name" : "The Sea of Monsters",
"author" : "Rick Riordan",
"series_t" : "Percy Jackson and the Olympians",
"sequence_i" : 2,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 6.49,
"pages_i" : 304
}
,
{
"id" : "978-1857995879",
"cat" : ["book","paperback"],
"name" : "Sophie's World : The Greek Philosophers",
"author" : "Jostein Gaarder",
"sequence_i" : 1,
"genre_s" : "fantasy",
"inStock" : true,
"price" : 3.07,
"pages_i" : 64
}
,
{
"id" : "978-1933988177",
"cat" : ["book","paperback"],
"name" : "Lucene in Action, Second Edition",
"author" : "Michael McCandless",
"sequence_i" : 1,
"genre_s" : "IT",
"inStock" : true,
"price" : 30.50,
"pages_i" : 475
}
]
Any ideas?
Upvotes: 0
Views: 268
Reputation: 52769
You can use the post.jar to feed the json to Solr as well
java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar *.json
Upvotes: 0
Reputation: 939
I believe you can only post xml using post.sh
XML should be of this format:
<add>
<doc>
<field name="employeeId">05991</field>
<field name="office">Bridgewater</field>
<field name="skills">Perl</field>
<field name="skills">Java</field>
</doc>
<doc>
<field name="employeeId">05992</field>
<field name="office">Bridgewater</field>
<field name="skills">Perl</field>
<field name="skills">Java</field>
</doc>
<doc>
<field name="employeeId">05993</field>
<field name="office">Bridgewater</field>
<field name="skills">Perl</field>
<field name="skills">Java</field>
</doc>
</add>
For more info:
post.sh: http://www.solrtutorial.com/solr-in-5-minutes.html
xml format: http://wiki.apache.org/solr/UpdateXmlMessages
If you want to post JSON, depending on version of Solr, you can configure JSON request handler in solrconfig.xml, and then post JSON as follows:
curl 'http://localhost:8983/solr/update/json?commit=true' --data-binary @books.json -H 'Content-type:application/json'
Please refer to this documentation on how to post json: http://wiki.apache.org/solr/UpdateJSON
Upvotes: 1