Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

PHP Apache Solr Adapter (Solr PHP Client)

branch: master

Merge pull request #1 from picur/master

Fixed issue adding same value twice if value was not initially an array on Document::setMultiValue call
latest commit 5366994e89
Yehuda Daniel authored
Octocat-spinner-32 php_doc_folder Nice release ! wohoo...
Octocat-spinner-32 root_folder Prevent adding same value twice if value is not an array
Octocat-spinner-32 tests_folder Nice release ! wohoo...
Octocat-spinner-32 Nice release ! wohoo...

PHP Apache Solr Adapter

Faster way search with solr in advance way.

You also invited to my Wiki


Put the files at classes dir (See bootstrap how it supposed to load the classes)

Configure classes/KoSolr.php: private $_connection_configurations = array( 'default-solr-configuration'=>array( 'server'=>'solr', 'port'=>8080, 'app_path'=>'/apache-solr-3.5.0', 'core'=>'members' ), );

Code Examples

Create Server Instance :

$instance_KoSolr = KoSolr::getInstance();
$KoSolr_Server_Instance = $instance_KoSolr->getServer();
// OR //
$KoSolr_Server_Instance = new KoSolr_Server('SOLR_SERVER',8080,'/apache-solr-3.5.0','CORENAME');

Delete (all=:) Documents


Adding/Updating document (note: each 1000 docs it will auto send them)

$doc = new KoSolr_Document();            
$doc->id = "id TEST";
$doc->name = 'xxx TEST';
$doc->Some_FIELD_NAME_OF_SOLR = 'some thing';
$update_request = $KoSolr_Server_Instance->create_update_request();
$response = $KoSolr_Server_Instance->execute($update_request);   

Search on solr :

$search_request = $KoSolr_Server_Instance->create_search_request();  
$search_request->select('*')->equals('id', '"id TEST"');
        ->equals('field1', 'should be equle')
        ->query('search string')
        ->setSort('field1 ASC');

$search_request->qf = 'activity_title^100 high^50 medium^5 low^0.01';   

$response = $server->execute($search_request);

$response->response['docs'] <-- This is results

Commit Optimize

Something went wrong with that request. Please try again.