You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Andrew Nagy <an...@villanova.edu> on 2007/12/02 23:04:57 UTC
(Unknown)
Hello - I am trying out the CSV importer and am curious with an error that I am consistently running into. What am I doing incorrectly here? I am importing a pipe delimited CSV file with quotes encapsulation.
Thanks
Andrew
curl http://localhost:8080/solr/update/csv?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
<p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
Re: RE: Re:
Posted by Brian Whitman <br...@variogr.am>.
On Dec 2, 2007, at 5:29 PM, Andrew Nagy wrote:
> Sorry for not explaining my self clearly: I have header=true as you
> can see from the curl command and there is a header line in the csv
> file.
was this your actual curl request?
>> curl http://localhost:8080/solr/update/csv?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv
>
you're escaping the ampersands if so... just keep them as &
RE: Re:
Posted by Andrew Nagy <an...@villanova.edu>.
Perfect! That did it.
Thanks for debugging this with me :)
Andrew
________________________________________
From: Ryan McKinley [ryantxu@gmail.com]
Sent: Sunday, December 02, 2007 7:10 PM
To: solr-user@lucene.apache.org
Subject: Re:
hymmm - give it a try without specifying "header=true"
Looks like if you don't specify header=true, it defaults to true - but
if you do, it throws an error.
I think there may be a bug... Yonik, should line 243 be:
} else if (!hasHeader) {
^!!!
ryan
Andrew Nagy wrote:
> Ryan, i didn't know there was a debugger - this could come in handy for other things. Thanks!
>
> I tried it out and it looks like everything is being parsed correctly when passing the url in quotes:
>
> curl "http://localhost:8080/solr/debug/dump?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.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">0</int><str name="handler">org.apache.solr.handler.DumpRequestHandler</str><lst name="params"><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst></lst><lst name="params"><str name="echoHandler">true</str><str name="echoParams">explicit</str><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst><lst name="context"><str name="path">/debug/dump</str></lst>
> </response>
>
> I tried again with update/csv and same error occurs:
> curl "http://localhost:8080/solr/update/csv?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.csv -H 'Content-type:text/plain; charset=utf-8'
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 400 </title>
> </head>
> <body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
> <p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
>
Re:
Posted by Yonik Seeley <yo...@apache.org>.
On Dec 2, 2007 7:10 PM, Ryan McKinley <ry...@gmail.com> wrote:
> hymmm - give it a try without specifying "header=true"
>
> Looks like if you don't specify header=true, it defaults to true - but
> if you do, it throws an error.
>
> I think there may be a bug... Yonik, should line 243 be:
>
> } else if (!hasHeader) {
> ^!!!
Yep, thanks for tracking that down!
I just committed your fix and a test.
-Yonik
Re:
Posted by Ryan McKinley <ry...@gmail.com>.
hymmm - give it a try without specifying "header=true"
Looks like if you don't specify header=true, it defaults to true - but
if you do, it throws an error.
I think there may be a bug... Yonik, should line 243 be:
} else if (!hasHeader) {
^!!!
ryan
Andrew Nagy wrote:
> Ryan, i didn't know there was a debugger - this could come in handy for other things. Thanks!
>
> I tried it out and it looks like everything is being parsed correctly when passing the url in quotes:
>
> curl "http://localhost:8080/solr/debug/dump?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.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">0</int><str name="handler">org.apache.solr.handler.DumpRequestHandler</str><lst name="params"><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst></lst><lst name="params"><str name="echoHandler">true</str><str name="echoParams">explicit</str><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst><lst name="context"><str name="path">/debug/dump</str></lst>
> </response>
>
> I tried again with update/csv and same error occurs:
> curl "http://localhost:8080/solr/update/csv?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.csv -H 'Content-type:text/plain; charset=utf-8'
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 400 </title>
> </head>
> <body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
> <p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
>
RE: Re:
Posted by Andrew Nagy <an...@villanova.edu>.
Ryan, i didn't know there was a debugger - this could come in handy for other things. Thanks!
I tried it out and it looks like everything is being parsed correctly when passing the url in quotes:
curl "http://localhost:8080/solr/debug/dump?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.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">0</int><str name="handler">org.apache.solr.handler.DumpRequestHandler</str><lst name="params"><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst></lst><lst name="params"><str name="echoHandler">true</str><str name="echoParams">explicit</str><str name="header">true</str><str name="separator">|</str><str name="commit">true</str><str name="encapsulator">"</str></lst><lst name="context"><str name="path">/debug/dump</str></lst>
</response>
I tried again with update/csv and same error occurs:
curl "http://localhost:8080/solr/update/csv?header=true&separator=%7C&encapsulator=%22&commit=true" --data-binary @homes.csv -H 'Content-type:text/plain; charset=utf-8'
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
<p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
Re:
Posted by Ryan McKinley <ry...@gmail.com>.
>
> I tried all the methods: converting & to %26, converting & to \& and encapsulating the url with quotes. All give the same error.
>
Try sending your curl command to:
http://localhost:8080/solr/debug/dump
When you are confident it is parsed properly, then try /update/csv --
the only way you can get the error you have is if "header=true" is not
read properly.
RE: RE: Re:
Posted by Andrew Nagy <an...@villanova.edu>.
Ugh ... I shouldn't be coding on a sunday night - especially after the eagles lost again!
I spelled separator correctly this time :) - But still no luck.
curl 'http://localhost:8080/solr/update/csv?header=true&separator=%7C&encapsulator=%22&commit=true&stream.file=import/homes.csv' -H 'Content-type:text/plain; charset=utf-8'
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
<p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
Re: RE: Re:
Posted by Brian Whitman <br...@variogr.am>.
On Dec 2, 2007, at 6:00 PM, Andrew Nagy wrote:
>> On Dec 2, 2007, at 5:43 PM, Ryan McKinley wrote:
>>>
>>>
>>> try \& rather then %26
>>
>>
>> or just put quotes around the whole url. I think curl does the
>> right thing here.
>
> I tried all the methods: converting & to %26, converting & to \& and
> encapsulating the url with quotes. All give the same error.
>
> curl http://localhost:8080/solr/update/csv?header=true\&seperator=%7C
> \&encapsulator=%22\&commit=true\&stream.file=import/homes.csv
seperator -> separator ? Does that help?
RE: Re:
Posted by Andrew Nagy <an...@villanova.edu>.
> On Dec 2, 2007, at 5:43 PM, Ryan McKinley wrote:
>>
>>
>> try \& rather then %26
>
>
> or just put quotes around the whole url. I think curl does the right thing here.
I tried all the methods: converting & to %26, converting & to \& and encapsulating the url with quotes. All give the same error.
curl http://localhost:8080/solr/update/csv?header=true\&seperator=%7C\&encapsulator=%22\&commit=true\&stream.file=import/homes.csv
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
<p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
Any other ideas? How do other do this?
Thanks
Andrew
Re: Re:
Posted by Brian Whitman <br...@variogr.am>.
On Dec 2, 2007, at 5:43 PM, Ryan McKinley wrote:
>
>
> try \& rather then %26
or just put quotes around the whole url. I think curl does the right
thing here.
Re:
Posted by Ryan McKinley <ry...@gmail.com>.
hymm, looks like an issue with command line curl and '%26'
When I run:
curl
http://localhost:8983/solr/debug/dump?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv\&indent=true
you can see the params it parsed:
<lst name="params">
<str name="echoParams">explicit</str>
<str name="echoHandler">true</str>
<str name="indent">true</str>
<str
name="header">true&seperator=|&encapsulator="&commit=true&stream.file=import/homes.csv</str>
</lst>
try \& rather then %26
ryan
Andrew Nagy wrote:
> Sorry for not explaining my self clearly: I have header=true as you can see from the curl command and there is a header line in the csv file.
>
> And sorry for the missing subject line.
>
> Andrew
> ________________________________________
> From: Ryan McKinley [ryantxu@gmail.com]
> Sent: Sunday, December 02, 2007 5:15 PM
> To: solr-user@lucene.apache.org
> Subject: Re:
>
> Andrew Nagy wrote:
>> Hello - I am trying out the CSV importer and am curious with an error that I am consistently running into. What am I doing incorrectly here? I am importing a pipe delimited CSV file with quotes encapsulation.
>>
>> Thanks
>> Andrew
>>
>> curl http://localhost:8080/solr/update/csv?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv
>>
>> <html>
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
>> <title>Error 400 </title>
>> </head>
>> <body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
>> <p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
>>
>
> take a look at the error:
>
> "CSVLoader: must specify fieldnames=<fields>* or header=true"
>
> either list the fieldnames or use the 1st line as the field names
> (header=true)
>
> ryan
>
>
>
>
>
RE: Re:
Posted by Andrew Nagy <an...@villanova.edu>.
Sorry for not explaining my self clearly: I have header=true as you can see from the curl command and there is a header line in the csv file.
And sorry for the missing subject line.
Andrew
________________________________________
From: Ryan McKinley [ryantxu@gmail.com]
Sent: Sunday, December 02, 2007 5:15 PM
To: solr-user@lucene.apache.org
Subject: Re:
Andrew Nagy wrote:
> Hello - I am trying out the CSV importer and am curious with an error that I am consistently running into. What am I doing incorrectly here? I am importing a pipe delimited CSV file with quotes encapsulation.
>
> Thanks
> Andrew
>
> curl http://localhost:8080/solr/update/csv?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 400 </title>
> </head>
> <body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
> <p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
>
take a look at the error:
"CSVLoader: must specify fieldnames=<fields>* or header=true"
either list the fieldnames or use the 1st line as the field names
(header=true)
ryan
Re:
Posted by Ryan McKinley <ry...@gmail.com>.
Andrew Nagy wrote:
> Hello - I am trying out the CSV importer and am curious with an error that I am consistently running into. What am I doing incorrectly here? I am importing a pipe delimited CSV file with quotes encapsulation.
>
> Thanks
> Andrew
>
> curl http://localhost:8080/solr/update/csv?header=true%26seperator=%7C%26encapsulator=%22%26commit=true%26stream.file=import/homes.csv
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
> <title>Error 400 </title>
> </head>
> <body><h2>HTTP ERROR: 400</h2><pre>CSVLoader: must specify fieldnames=<fields>* or header=true</pre>
> <p>RequestURI=/solr/update/csv</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
>
take a look at the error:
"CSVLoader: must specify fieldnames=<fields>* or header=true"
either list the fieldnames or use the 1st line as the field names
(header=true)
ryan