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 Daniel Andersson <da...@polkabrothers.com> on 2008/01/23 00:37:13 UTC
SolrPhpClient with example jetty
Hi (again)
I'm trying to add documents using the SolrPhpClient (if there's a
specific mailinglist for it, please let me know and I'll ask there
instead).
I've searched the net for "missing content stream", but found nothing
that makes sense.
This is what solr spits out when I run the example code that came
with SolrPhpClient (see bottom for code):
Jan 23, 2008 12:32:46 AM org.apache.solr.core.SolrCore execute
INFO: null q=solrpingquery&qt=standard 0 1
Jan 23, 2008 12:32:46 AM org.apache.solr.core.SolrException log
SEVERE: org.apache.solr.core.SolrException: missing content stream
at
org.apache.solr.handler.XmlUpdateRequestHandler.handleRequestBody
(XmlUpdateRequestHandler.java:75)
at org.apache.solr.handler.RequestHandlerBase.handleRequest
(RequestHandlerBase.java:77)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:658)
at org.apache.solr.servlet.SolrDispatchFilter.execute
(SolrDispatchFilter.java:191)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter
(SolrDispatchFilter.java:159)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1089)
at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java:365)
at org.mortbay.jetty.security.SecurityHandler.handle
(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle
(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle
(ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerCollection.handle
(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest
(HttpConnection.java:502)
at org.mortbay.jetty.HttpConnection$RequestHandler.content
(HttpConnection.java:835)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
at org.mortbay.jetty.HttpParser.parseAvailable
(HttpParser.java:208)
at org.mortbay.jetty.HttpConnection.handle
(HttpConnection.java:378)
at org.mortbay.jetty.bio.SocketConnector$Connection.run
(SocketConnector.java:226)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run
(BoundedThreadPool.java:442)
Jan 23, 2008 12:32:46 AM org.apache.solr.core.SolrCore execute
INFO: /update wt=json&<add allowDups="false"+overwritePending%
3D"true"+overwriteCommitted%3D"true"><doc><field+name%
3D"id">47967d1e4b93b</field><field+name%3D"title">Some+Title</
field><field+name%3D"content">Some+content+for+this+wonderful
+document.+Blah+blah+blah.</field></doc></add> 0 3
code:
$solr = new Apache_Solr_Service("localhost", 8983, "/solr");
if ($solr->ping())
{
$document = new Apache_Solr_Document();
$document->id = uniqid(); //or something else suitably unique
$document->title = 'Some Title';
$document->content = 'Some content for this wonderful document. Blah
blah blah.';
$solr->addDocument($document); //if you're going to be adding
documents in bulk using addDocuments
//with an array of documents is faster
}
Thanks in advance!
/ d
Re: SolrPhpClient with example jetty
Posted by Daniel Andersson <da...@polkabrothers.com>.
On Jan 23, 2008, at 12:47 AM, Brian Whitman wrote:
>>
>> $document->title = 'Some Title';
>> $document->content = 'Some content for this wonderful document.
>> Blah blah blah.';
>>
>
> did you change the schema? There's no title or content field in the
> default example schema. But I believe solr does output different
> errors for that.
This bit I didn't know about (again, a newbie-guide would be nice :),
but changed it. Still same error, even when I just try to delete
everything:
Jan 23, 2008 1:07:37 AM org.apache.solr.core.SolrException log
SEVERE: org.apache.solr.core.SolrException: missing content stream
at
org.apache.solr.handler.XmlUpdateRequestHandler.handleRequestBody
(XmlUpdateRequestHandler.java:75)
at org.apache.solr.handler.RequestHandlerBase.handleRequest
(RequestHandlerBase.java:77)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:658)
at org.apache.solr.servlet.SolrDispatchFilter.execute
(SolrDispatchFilter.java:191)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter
(SolrDispatchFilter.java:159)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1089)
at org.mortbay.jetty.servlet.ServletHandler.handle
(ServletHandler.java:365)
at org.mortbay.jetty.security.SecurityHandler.handle
(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle
(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle
(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle
(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle
(ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerCollection.handle
(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle
(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest
(HttpConnection.java:502)
at org.mortbay.jetty.HttpConnection$RequestHandler.content
(HttpConnection.java:835)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
at org.mortbay.jetty.HttpParser.parseAvailable
(HttpParser.java:208)
at org.mortbay.jetty.HttpConnection.handle
(HttpConnection.java:378)
at org.mortbay.jetty.bio.SocketConnector$Connection.run
(SocketConnector.java:226)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run
(BoundedThreadPool.java:442)
Jan 23, 2008 1:07:37 AM org.apache.solr.core.SolrCore execute
INFO: /update <delete fromPending="true"+fromCommitted%
3D"true"><query>*:*</query></delete>&wt=json 0 7
/ d
Re: SolrPhpClient with example jetty
Posted by Brian Whitman <br...@variogr.am>.
>
> $document->title = 'Some Title';
> $document->content = 'Some content for this wonderful document.
> Blah blah blah.';
>
did you change the schema? There's no title or content field in the
default example schema. But I believe solr does output different
errors for that.
Re: SolrPhpClient with example jetty
Posted by Daniel Andersson <da...@polkabrothers.com>.
> I'm trying to add documents using the SolrPhpClient (if there's a
> specific mailinglist for it, please let me know and I'll ask there
> instead).
>
> I've searched the net for "missing content stream", but found
> nothing that makes sense.
I have now (finally) found the solution!
If I change the following line in Service.php/_sendRawPost():
stream_context_set_option($this->_postContext, 'http', 'header',
'Content-Type: ' . $contentType. "\r\n");
to
stream_context_set_option($this->_postContext, 'http', 'header', array
('Content-Type: ' . $contentType));
It all works fine.
I'm far from sure why this is, but it seems like I'm quite alone in
running into this problem. Maybe it's something to do with the fact
that I'm running this on a PPC mac (endian-things)?
Donovan, thanks for looking into my problem, and thank you for
SolrPhpClient :)
/ d