user3025387
user3025387

Reputation: 1

Document is missing mandatory uniqueKey field during solr csv import on windows

I am trying to create a very simple search index on solr 4.5.1 with just two fields 'id' and 'name' by using a csv file. Running on Windows 8.

When I run:

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

I get the error: Document is missing mandatory uniqueKey field: id

When I copy/paste the content of the file into the csv import function in the solr-admin ui (documents->document type:csv) then it works.

What am I missing? Thx for any help!

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

The simplest csv file I tried is:

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

Upvotes: 0

Views: 1134

Answers (2)

Budia
Budia

Reputation: 113

It's all about file encoding, it works only with ANSI encoding

here is the same issue

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

Upvotes: 0

Arun
Arun

Reputation: 1797

I do not have windows 8 , but i tried with windows 7. I installed 4.5.1 and ran your curl on windows/cygwin as:

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

Where test.csv is: id,name LXOxjksM2z, The simplest cookbook you can ever find

Solr indexed properly and i was able to query from admin for id:LXOxjksM2z and found 1 document as :

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

Not sure what is wrong on windows 8.

Upvotes: 0

Related Questions