2013-11-23 49 views
0

我想通過使用csv文件在solr 4.5.1上創建一個非常簡單的搜索索引,只有兩個字段'id'和'name'。運行在Windows 8在Windows上solr csv導入時文檔缺少強制uniqueKey字段

當我運行:

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

我得到的錯誤:找不到文檔強制唯一鍵字段:ID

當我複製/粘貼文件的內容到CSV導入功能在solr-admin ui(文件 - >文件類型:csv)然後它工作。

我錯過了什麼? Thx任何幫助!

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

回答

0

我沒有Windows 8的,但我想在Windows 7我安裝了4.5.1跑您在Windows捲曲/ Cygwin的爲:

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

+0

同時檢查csv文件是否有什麼奇怪的地方。你可以發佈你的CSV文件的地方,我可以下載並嘗試? – Arun