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 Peter Rochford <ro...@cpi.com> on 2011/10/03 16:59:29 UTC
Broken Simple html Form
Hi Solr Users,
Im new to using Solr and trying to implement it as a search engine for our
company web site using the simple html form provided by
donovan....@gmail.com at
http://code.google.com/p/solr-php-client/wiki/ExampleUsage. The example
provided via this web page fails to work for me. From what I can determine
the php bails when trying to access any items in the object returned by
$solr->search. For example, the php file stops when executing the second
statement in the following two lines of code:
$response = $solr->search( $query, $offset, $limit);
$test = $response->response->numFound;
The problem appears to be due to the private protections placed on the
object returned from $solr->search. Enclosed between the horizontal lines
below is some code Ive inserted within the first try statement to provide
some output.
--------------------------------------------
try
{
print("query = $query <br>"); //debug
$results = $solr->search($query, 0, $limit);
echo "Executing print_r(\$results) <br>"; //debug
echo "result contents: ", print_r($results), "<br>"; //debug
print "<br>";
echo "http status: ", $results->getHttpStatusMessage(), "<br>";
$raw_response = $results->getRawResponse();
echo "Executing print_r(\$results->getRawResponse()) <br>"; //debug
echo "Raw Response: ", print_r($raw_response), "<br><br>"; //returns 800
char string
print "Executing: echo \$results->response->numFound; <br>";
echo $results->response->numFound;
print "<br> Passed new test load <br>";
}
catch (Exception $e)
{
// in production you'd probably log or email this error to an admin
// and then show a special message to the user but for this example
// we're going to show the full exception
die("<html><head><title>SEARCH EXCEPTION</title><body><pre>{$e
>__toString()}</pre></body></html>");
}
--------------------------------------------
The output obtained is shown between the horizontal lines below. From the
output it is clear that Solr is working fine and that the php file
encounters a problem when executing $results->response->numFound because it
never gets to the Passed new test load statement.
--------------------------------------------
query = rochford
Executing print_r($results)
result contents: Apache_Solr_Response Object ( [_response:protected] =>
Apache_Solr_HttpTransport_Response Object ( [_statusCode:private] => 200
[_statusMessage:private] => OK [_mimeType:private] => text/plain
[_encoding:private] => UTF-8 [_responseBody:private] =>
{"responseHeader":{"status":0,"QTime":1,"params":{"start":"0","q":"rochford"
,"json.nl":"map","wt":"json","rows":"10"}},"response":{"numFound":1,"start":
0,"docs":[{"id":"SOLR1000","name":"Solr, the Enterprise Search
Server","manu":"Apache Software
Foundation","price":0.0,"popularity":10,"inStock":true,"incubationdate_dt":"
2006-01-17T00:00:00Z","cat":["software","search"],"features":["Peter
Rochford added text here!","Advanced Full-Text Search Capabilities using
Lucene","Optimized for High Volume Web Traffic","Standards Based Open
Interfaces - XML and HTTP","Comprehensive HTML Administration
Interfaces","Scalability - Efficient Replication to other Solr Search
Servers","Flexible and Adaptable with XML configuration and Schema","Good
unicode support: héllo (hello with an accent over the e)"]}]}} )
[_isParsed:protected] => [_parsedData:protected] =>
[_createDocuments:protected] => 1 [_collapseSingleValueArrays:protected] =>
1 ) 1
http status: OK
Executing print_r($results->getRawResponse())
Raw Response:
{"responseHeader":{"status":0,"QTime":1,"params":{"start":"0","q":"rochford"
,"json.nl":"map","wt":"json","rows":"10"}},"response":{"numFound":1,"start":
0,"docs":[{"id":"SOLR1000","name":"Solr, the Enterprise Search
Server","manu":"Apache Software
Foundation","price":0.0,"popularity":10,"inStock":true,"incubationdate_dt":"
2006-01-17T00:00:00Z","cat":["software","search"],"features":["Peter
Rochford added text here!","Advanced Full-Text Search Capabilities using
Lucene","Optimized for High Volume Web Traffic","Standards Based Open
Interfaces - XML and HTTP","Comprehensive HTML Administration
Interfaces","Scalability - Efficient Replication to other Solr Search
Servers","Flexible and Adaptable with XML configuration and Schema","Good
unicode support: héllo (hello with an accent over the e)"]}]}}1
Executing: echo $results->response->numFound;
--------------------------------------------
Clearly the search for "Rochford" is successful. The problem is I cannot
access the item in the $results object.
Note that I am using the following versions of Solr, PHP, and Java:
Apache-Solr-3.3.0
PHP 5.3.8 (cli) (built: Aug 29 2011 21:03:55)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
Any suggestions on the cause of the problem and what is the solution would
be appreciated.
Thanks,
Peter Rochford
Dr. Peter Rochford
Computational Physics, Inc.
<http://maps.google.com/maps?client=safari&q=5201+Port+Royal+Rd,+Springfield
,+VA.&oe=UTF-8&ie=UTF8&hq=&hnear=5201+Port+Royal+Rd,+Springfield,+Fairfax,+V
irginia+22161&gl=us&ei=B9tVTIC_E8L68AaTyYjfCA&ved=0CBMQ8gEwAA&z=16> 8001
Braddock Road
Suite 210
Springfield, VA 22151-2110
Voice: (703) 764-7501
Fax: (703) 764-7500
www.cpi.com