Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
basdenooijer committed Apr 16, 2012
2 parents ad6bcdb + 5438f5c commit 7b57f3e
Show file tree
Hide file tree
Showing 92 changed files with 3,424 additions and 210 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: php
phps:
- 5.4
- 5.3
script: phpunit -c phpunit.xml.dist
22 changes: 0 additions & 22 deletions README

This file was deleted.

26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Solarium PHP Solr client library

Solarium is a PHP Solr client that not only facilitates Solr communication but
also tries to accurately model Solr concepts.
Please see the project website for a more detailed description.

## Project website
http://www.solarium-project.org/

## License:
See the COPYING file or view online
https://github.com/basdenooijer/solarium/blob/master/COPYING

## Issue tracker
http://github.com/basdenooijer/solarium/issues

## Contributors
https://github.com/basdenooijer/solarium/contributors

## API docs
http://api.solarium-project.org/

## Travis Continuous Integration status

* Develop branch [![Develop build status](https://secure.travis-ci.org/basdenooijer/solarium.png?branch=develop)](http://travis-ci.org/basdenooijer/solarium)
* Master branch [![Develop build status](https://secure.travis-ci.org/basdenooijer/solarium.png?branch=master)](http://travis-ci.org/basdenooijer/solarium)
12 changes: 4 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
"name": "solarium/solarium",
"type": "library",
"description": "PHP Solr client",
"keywords": ["solr", "search"],
"keywords": ["solr", "search", "php"],
"homepage": "http://www.solarium-project.org",
"version": "2.3.0",
"version": "2.4.0",
"license": "NewBSD",
"authors": [
{
"name": "Bas de Nooijer",
"email": "[email protected]"
},
{
"name": "Gasol Wu",
"email": "[email protected]"
"name": "See GitHub contributors",
"homepage": "https://github.com/basdenooijer/solarium/contributors"
}
],
"require": {
Expand Down
2 changes: 1 addition & 1 deletion examples/1.1-check-solarium-and-ping.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// execute the ping query
try{
$result = $client->ping($ping);
echo 'Ping query succesful';
echo 'Ping query successful';
echo '<br/><pre>';
var_dump($result->getData());
}catch(Solarium_Exception $e){
Expand Down
2 changes: 1 addition & 1 deletion examples/1.3-basic-update.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
2 changes: 1 addition & 1 deletion examples/2.2.1-add-docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
2 changes: 1 addition & 1 deletion examples/2.2.2-delete-by-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
2 changes: 1 addition & 1 deletion examples/2.2.3-delete-by-id.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
2 changes: 1 addition & 1 deletion examples/2.2.4-optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
2 changes: 1 addition & 1 deletion examples/2.2.5-rollback.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// this executes the query and returns the result
$result = $client->update($update);

echo '<b>Update query executed<b><br/>';
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();

Expand Down
39 changes: 39 additions & 0 deletions examples/2.6-suggester-query.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

require('init.php');
htmlHeader();

// create a client instance
$client = new Solarium_Client($config);

// get a suggester query instance
$query = $client->createSuggester();
$query->setQuery('ap ip v'); //multiple terms
$query->setDictionary('suggest');
$query->setOnlyMorePopular(true);
$query->setCount(10);
$query->setCollate(true);

// this executes the query and returns the result
$resultset = $client->suggester($query);

echo '<b>Query:</b> '.$query->getQuery().'<hr/>';

// display results for each term
foreach ($resultset as $term => $termResult) {
echo '<h3>' . $term . '</h3>';
echo 'NumFound: '.$termResult->getNumFound().'<br/>';
echo 'StartOffset: '.$termResult->getStartOffset().'<br/>';
echo 'EndOffset: '.$termResult->getEndOffset().'<br/>';
echo 'Suggestions:<br/>';
foreach($termResult as $result){
echo '- '.$result.'<br/>';
}

echo '<hr/>';
}

// display collation
echo 'Collation: '.$resultset->getCollation();

htmlFooter();
41 changes: 41 additions & 0 deletions examples/6.4-dereferenced-params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require('init.php');
htmlHeader();

// create a client instance and get a select query instance
$client = new Solarium_Client($config);




// first an example manually defining dereferenced params
$query = $client->createSelect();
$helper = $query->getHelper();

$join = $helper->qparser('join', array('from' => 'manu_id', 'to' => 'id'), true);
$queryString = $join . 'id:1';
$query->setQuery($queryString);
$request = $client->createRequest($query);

// output resulting url with dereferenced params
echo urldecode($request->getUri()) . '<hr/>';




// this second example gives the exact same result, using the special join helper
$query = $client->createSelect();
$helper = $query->getHelper();

$join = $helper->join('manu_id', 'id', true);
$queryString = $join . 'id:1';
$query->setQuery($queryString);
$request = $client->createRequest($query);

echo urldecode($request->getUri());




htmlFooter();
51 changes: 51 additions & 0 deletions examples/7.4-plugin-parallelexecution.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
require('init.php');

htmlHeader();

// create a client instance and autoload the customize request plugin
$client = new Solarium_Client($config);
$parallel = $client->getPlugin('parallelexecution');

// Add a delay param to better show the effect, as an example Solr install with
// only a dozen documents is too fast for good testing
// This param only works with the correct Solr plugin,
// see http://www.raspberry.nl/2012/01/04/solr-delay-component/
// If you don't have to plugin the example still works, just without the delay.
$customizer = $client->getPlugin('customizerequest');
$customizer->createCustomization(array(
'key' => 'delay',
'type' => 'param',
'name' => 'delay',
'value' => '500',
'persistent' => true
));

// create two queries to execute in an array. Keys are important for fetching the results later!
$queryInstock = $client->createSelect()->setQuery('inStock:true');
$queryLowprice = $client->createSelect()->setQuery('price:[1 TO 300]');

// first execute the queries the normal way and time it
$start = microtime(true);
$client->execute($queryInstock);
$client->execute($queryLowprice);
echo 'Execution time for normal "serial" execution of two queries: ' . round(microtime(true)-$start, 3);


echo '<hr/>';


// now execute the two queries parallel and time it
$start = microtime(true);
$parallel->addQuery('instock', $queryInstock);
$parallel->addQuery('lowprice', $queryLowprice);
$results = $parallel->execute();
echo 'Execution time for parallel execution of two queries: ' . round(microtime(true)-$start, 3);


htmlFooter();

// Note: for this example on a default Solr index (with a tiny index) running on localhost the performance gain is
// minimal to none, sometimes even slightly slower!
// In a realworld scenario with network latency, a bigger dataset, more complex queries or multiple solr instances the
// performance gain is much more.
51 changes: 51 additions & 0 deletions examples/7.5-plugin-bufferedadd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
require('init.php');

// this very simple plugin is used to show some events
class simpleDebug extends Solarium_Plugin_Abstract
{
protected $_output = array();

public function display()
{
echo implode('<br/>', $this->_output);
}

public function eventBufferedAddFlushStart($buffer) {
$this->_output[] = 'Flushing buffer (' . count($buffer) . 'docs)';
}
}

htmlHeader();

// create a client instance and autoload the buffered add plugin
$client = new Solarium_Client($config);
$buffer = $client->getPlugin('bufferedadd');
$buffer->setBufferSize(10); // this is quite low, in most cases you can use a much higher value

// also register a plugin for outputting events
$debug = new simpleDebug();
$client->registerPlugin('debugger', $debug);

// let's insert 25 docs
for ($i=1; $i<=25; $i++) {

// create a new document with dummy data and add it to the buffer
$data = array(
'id' => 'test_'.$i,
'name' => 'test for buffered add',
'price' => $i,
);
$buffer->createDocument($data);

// alternatively you could create document instances yourself and use the addDocument(s) method
}

// At this point two flushes will already have been done by the buffer automatically (at the 10th and 20th doc), now
// manually flush the remainder. Alternatively you can use the commit method if you want to include a commit command.
$buffer->flush();

// In total 3 flushes (requests) have been sent to Solr. This should be visible in this output:
$debug->display();

htmlFooter();
26 changes: 26 additions & 0 deletions examples/7.6-plugin-prefetchiterator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
require('init.php');

htmlHeader();

// create a client instance
$client = new Solarium_Client($config);

// get a select query instance
$query = $client->createSelect();
$query->setFields(array('id'));

// get a plugin instance and apply settings
$prefetch = $client->getPlugin('prefetchiterator');
$prefetch->setPrefetch(2); //fetch 2 rows per query (for real world use this can be way higher)
$prefetch->setQuery($query);

// display the total number of documents found by solr
echo 'NumFound: ' . count($prefetch);

// show document IDs using the resultset iterator
foreach ($prefetch as $document) {
echo '<hr/>ID: '. $document->id;
}

htmlFooter();
8 changes: 7 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ <h1>Solarium examples</h1>
</ul>

<li><a href="2.5-terms-query.php">2.5 Terms query</a></li>

<li><a href="2.6-suggester-query.php">2.6 Suggester query</a></li>
</ul>

<li>4. Usage modes</li>
Expand Down Expand Up @@ -113,13 +115,17 @@ <h1>Solarium examples</h1>
</ul>
<li><a href="6.2-escaping.php">6.2 Escaping</a></li>
<li><a href="6.3-placeholder-syntax.php">6.3 Placeholder syntax</a></li>
<li><a href="6.4-dereferenced-params.php">6.4 Dereferenced params</a></li>
</ul>

<li>7. Plugins</li>
<ul style="list-style:none;">
<li><a href="7.1-plugin-loadbalancer.php">7.1 Loadbalancer</a></li>
<li><a href="7.2-plugin-postbigrequest.php">7.2 Post Big Requests</a></li>
<li><a href="7.3-plugin-customizerequest.php">7.3 customize Requests</a></li>
<li><a href="7.3-plugin-customizerequest.php">7.3 Customize Requests</a></li>
<li><a href="7.4-plugin-parallelexecution.php">7.4 Parallel Execution</a></li>
<li><a href="7.5-plugin-bufferedadd.php">7.5 Buffered Add for documents</a></li>
<li><a href="7.6-plugin-prefetchiterator.php">7.6 Prefetch iterator for select queries</a></li>
</ul>

</ul>
Expand Down
Loading

0 comments on commit 7b57f3e

Please sign in to comment.