【问题标题】:Document is missing mandatory uniqueKey field during solr csv import on windows在 windows 上的 solr csv 导入期间,文档缺少强制性的 uniqueKey 字段
【发布时间】:2013-11-23 17:16:00
【问题描述】:

我正在尝试使用 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 (documents->document type: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

【问题讨论】:

    标签: solr


    【解决方案1】:

    我没有 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 在哪里: 身份证,姓名 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 出了什么问题。

    【讨论】:

    • 还要检查 csv 文件是否有任何奇怪之处。你能把你的 csv 文件贴在我可以下载和尝试的地方吗?
    【解决方案2】:

    这都是关于文件编码的,它只适用于 ANSI 编码

    同样的问题

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

    【讨论】:

      猜你喜欢
      • 2018-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多