hi
i am trying to use pache solr with php i have bitnami apache solr and php-solr client installed , i am trying to run the example code -
<?php
-
require_once( 'Solr/Service.php' );
-
-
//
-
//
-
// Try to connect to the named server, port, and url
-
//
-
$solr = new Apache_Solr_Service( 'localhost', '8983', '/solr' );
-
-
if ( ! $solr->ping() ) {
-
echo 'Solr service not responding.';
-
exit;
-
}
-
//
-
//
-
// Create two documents to represent two auto parts.
-
// In practice, documents would likely be assembled from a
-
// database query.
-
//
-
$parts = array(
-
'spark_plug' => array(
-
-
'name' => 'Spark plug',
-
-
),
-
'windshield' => array(
-
-
'name' => 'Windshield',
-
-
)
-
);
-
-
$documents = array();
-
-
foreach ( $parts as $item => $fields ) {
-
$part = new Apache_Solr_Document();
-
-
foreach ( $fields as $key => $value ) {
-
if ( is_array( $value ) ) {
-
foreach ( $value as $datum ) {
-
$part->setMultiValue( $key, $datum );
-
}
-
}
-
else {
-
$part->$key = $value;
-
}
-
}
-
-
$documents[] = $part;
-
}
-
-
//
-
//
-
// Load the documents into the index
-
//
-
try {
-
$solr->addDocuments( $documents );
-
$solr->commit();
-
$solr->optimize();
-
}
-
catch ( Exception $e ) {
-
echo $e->getMessage();
-
}
-
-
-
//
-
//
-
// Run some queries. Provide the raw path, a starting offset
-
// for result documents, and the maximum number of result
-
// documents to return. You can also use a fourth parameter
-
// to control how results are sorted and highlighted,
-
// among other options.
-
//
-
$offset = 0;
-
$limit = 10;
-
-
$queries = array(
-
'name: plug'
-
);
-
-
-
foreach ( $queries as $query ) {
-
$response = $solr->search( $query, $offset, $limit );
-
echo '<pre>';
-
echo $response->getHttpStatus();
-
print_r( $response->getRawResponse() );
-
echo $response->response->numFound;
-
echo '</pre>';
-
break;
-
if ( $response->getHttpStatus() == 200 ) {
-
// print_r( $response->getRawResponse() );
-
-
if ( $response->response->numFound > 0 ) {
-
echo "$query <br />";
-
-
foreach ( $response->response->docs as $doc ) {
-
echo "$doc->partno $doc->name <br />";
-
}
-
-
echo '<br />';
-
}
-
}
-
else {
-
echo $response->getHttpStatusMessage();
-
}
-
}
-
?>
-
but it is continiously giving 400 bad request error , can someone help me in this regard , i googled and most of the issues regarding 400 bad request were suggesting to define the fields in the schema.xml but one thing i cant understand is that for the very first time is there any need to load data into it which can be searched , I am confused there are 3 diferent things apache solr and php solr client i downloaded the phpsolr client from
http://code.google.com/p/solr-php-client/downloads/list
regards,
Omer Aslam
1 2005
i have solved it , this was on the commit() function because solr 4.0 and up versions have deprecated the waitflush parameter in the xml tag , we need to remove this from the optimize() function in the service.php file , do note that we donot need to remove the function parameter but the actual xml tag attribute that is mentioned inthe $rawpost variable
regards,
Omer Aslam
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Rybak |
last post by:
hi, everyone.
I'm writing a 2-players game that should support network mode. I'm now
testing it on 1 PC since I don't have 2. I directly use sockets, and
both client and server do...
|
by: cjl |
last post by:
Hey all:
I know that it is silly in the age of Google to 'lose' something on the
internet, but I recently checked out a project that had implemented a
database with a subset of SQL in pure...
|
by: Timothy Shih |
last post by:
Hi,
I am having a freezing issue with my application. My application serves
several remotable objects, all of which must be initialized before their
use. Furthermore, some of them depend on each...
|
by: Ken Allen |
last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other
languages and done some COM work for a number of years. I am attempting to
understand how to map an older program...
|
by: rs |
last post by:
how I the client tell the server that the socket is closed? or this there an
even that informs the server that the clients socket is close?
Oh, I am using vb.net 2003
Thanks
| |
by: Ankit Aneja |
last post by:
i am doing here some some socket-client work in C# windows service
it is working fine for multiple clients
now i want to limit these multiple clients to 25 for example
i want that when service...
|
by: J Huntley Palmer |
last post by:
I am having a horrific time integrating uw-imap's c-client for imap
support in php. The problem is a whole bunch of "Text relocation remains
referenced against symbol" errors during
linking....
|
by: khu84 |
last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output.
Following is the server code:-
<?php
function...
|
by: nsaffary |
last post by:
hi
I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |