在Windows上的solr csv导入期间,Document缺少必需的uniqueKey字段

时间:2013-11-23 17:16:01

标签: solr

我正在尝试使用csv文件在solr 4.5.1上创建一个非常简单的搜索索引,只有两个字段'id'和'name'。在Windows 8上运行。

当我跑步时:

curl http://localhost:8983/solr/update/csv --data-binary @mydata.csv -H 
  "Content-type:text/plain; charset=utf-8"

我收到错误:文档缺少必需的uniqueKey字段:id

当我将文件内容复制/粘贴到solr-admin ui(文档 - >文档类型:csv)中的csv导入功能时,它可以正常工作。

我错过了什么?感谢任何帮助!

我的schema.xml:

<fields>       
   <field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> 
   <!-- points to the root document of a block of nested documents -->
   <field name="_root_" type="string" indexed="true" stored="false"/>
   <field name="name" type="text_en" indexed="true" stored="true"/>
   <field name="_version_" type="long" indexed="true" stored="true" multiValued="true"/>
</fields>

<uniqueKey>id</uniqueKey>

我尝试过的最简单的csv文件是:

id,name
LXOxjksM2z, The simplest cookbook you can ever find

2 个答案:

答案 0 :(得分:0)

我没有Windows 8,但我尝试使用Windows 7.我安装了4.5.1并在windows / cygwin上运行你的curl:

/cygdrive/c/Installs/solr-4.5.1/solr-4.5.1/example/exampledocs
$ curl http://localhost:8983/solr/update/csv --data-binary @test.csv -H "Content-type:text/plain; charset=utf-8"
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="QTime">17</int></lst>
</response>

test.csv在哪里: ID,名称 LXOxjksM2z,你能找到的最简单的食谱

Solr索引正确,我能够从管理员查询id:LXOxjksM2z并找到1个文件:

"response": {
    "numFound": 1,
    "start": 0,
    "docs": [
      {
        "id": "LXOxjksM2z",
        "name": " The simplest cookbook you can ever finds",
        "_version_": 1452541521661264000
      }
    ]
  }
}

不确定Windows 8有什么问题。

答案 1 :(得分:0)

关于文件编码,它仅适用于ANSI编码

这是同样的问题

Apach Solr import index from csv(UTF-8) error: undefined field