什么json格式是solr期待的

时间:2013-06-13 05:31:57

标签: json solr

我是solr的新手,我正在尝试使用books.json索引exampledocs目录中的post.sh文件:

但我得到的是:

enter image description here

这是books.json文件:

[
  {
    "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
  }
]

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

我相信你只能使用post.sh发布xml

XML应该采用以下格式:

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

欲了解更多信息:

post.sh:http://www.solrtutorial.com/solr-in-5-minutes.html

xml格式:http://wiki.apache.org/solr/UpdateXmlMessages


如果要发布JSON,根据Solr的版本,您可以在solrconfig.xml中配置JSON请求处理程序,然后按如下方式发布JSON:

curl 'http://localhost:8983/solr/update/json?commit=true' --data-binary @books.json -H 'Content-type:application/json'

请参阅此文档,了解如何发布json:http://wiki.apache.org/solr/UpdateJSON

答案 1 :(得分:0)

您也可以使用post.jar将json提供给Solr

java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar *.json