0

我是 solr 的新手,我正在尝试使用以下命令索引books.jsonexampledocs 目录中的文件post.sh

但我得到的是:

在此处输入图像描述

这是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
  }
]

有任何想法吗?

4

2 回答 2

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

于 2013-06-13T06:58:57.747 回答
0

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

java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar *.json
于 2013-06-21T04:25:22.703 回答