Skip to content

Instantly share code, notes, and snippets.

View basdenooijer's full-sized avatar

Bas de Nooijer basdenooijer

View GitHub Profile
<html><head><title>Add docs</title></head><body>
<?php
require('../library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
// create a client instance
$client = new Solarium_Client();
// create a new document for the data
@basdenooijer
basdenooijer / demo.php
Created May 4, 2011 06:26
Solarium example with facet filtering and pagination
<?php
require('../library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
$client = new Solarium_Client();
$client->setHost('192.168.1.2');
$client->setCore('geonames');
$query = new Solarium_Query_Select;
@basdenooijer
basdenooijer / Config.ini
Created April 15, 2011 13:44
Solarium configuration mode
[solr]
; client connection settings
client.host = "192.168.1.2"
client.port = 8983
client.path = /solr/
client.core = geonames
; a complex select query based on configuration
@basdenooijer
basdenooijer / 1-ReadOnlyDocument.php
Created March 30, 2011 12:04
Solarium document examples
<?php
// make Solarium available
require('Solarium/Autoloader.php');
Solarium_Autoloader::register();
// create a client instance
$client = new Solarium_Client;
$client->setHost('192.168.1.2');
$client->setPort(8983);
@basdenooijer
basdenooijer / 1-configureAdapterInstance.php
Created March 30, 2011 07:44
Solarium client adapter ZendHttp examples
<?php
// this example assumes Solarium and Zend_Framework are in your include_path
// make Solarium available
require('Solarium/Autoloader.php');
Solarium_Autoloader::register();
// make Zend Framework available
require('Zend/Loader/Autoloader.php');
@basdenooijer
basdenooijer / 1-deleteByQuery.php
Created February 22, 2011 12:28
Solarium update examples
<?php
// this is the easiest way to add a delete command, by using one of the helper methods:
$query = new Solarium_Query_Update;
$query->addDeleteQuery('*:*');
$query->addCommit();
$client->update($query);
// alternatively you can construct the command yourself:
@basdenooijer
basdenooijer / basicSelect.php
Created February 22, 2011 10:43
Solarium select examples
<?php
// A query without any settings will use default values.
// This will result in a "*:*" query, 10 rows, all fields.
$query = new Solarium_Query_Select;
$result = $client->select($query);
echo 'Number of results found: ' . $result->getNumFound();
// The resultset is iterable, you could also use $result->getDocuments() to get an array with documents.
@basdenooijer
basdenooijer / pingExample.php
Created February 22, 2011 10:20
Solarium ping example
<?php
$client = new Solarium_Client;
$client->setHost('127.0.0.1');
$client->setPort(8983);
$client->setPath('/solr/');
$client->setCore('core0');
$query = new Solarium_Query_Ping;
$result = $client->ping($query);
@basdenooijer
basdenooijer / CheckAutoloader.php
Created February 21, 2011 06:50
Include / autoload Solarium
<?php
echo Solarium_Version::VERSION;
@basdenooijer
basdenooijer / configuration.php
Created February 18, 2011 14:03
Create a Solarium_Client instance in three different ways
<?php
$config = array(
'host' => '192.168.1.2',
'port' => 8983,
'path' => '/solr/',
'core' => 'geonames',
);
$client = new Solarium_Client($config);