Commit 2e589683 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge branch 'feature/examples' into develop

parents 1b555412 1ec77754
config.php
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// check solarium version available
echo 'Solarium library version: ' . Solarium_Version::VERSION . ' - ';
// create a client instance
$client = new Solarium_Client($config);
// create a ping query
$ping = $client->createPing();
// execute the ping query
try{
$client->ping($ping);
echo 'Ping query succesful';
}catch(Solarium_Exception $e){
echo 'Ping query failed';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
if ($_POST) {
// if data is posted add it to solr
// create a new document for the data
// please note that any type of validation is missing in this example to keep it simple!
$doc = new Solarium_Document_ReadWrite();
$doc->id = $_POST['id'];
$doc->name = $_POST['name'];
$doc->price = $_POST['price'];
// create a client instance
$client = new Solarium_Client($config);
// get an update query instance
$update = $client->createUpdate();
// add the document and a commit command to the update query
$update->addDocument($doc);
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed<b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
} else {
// if no data is posted show a form
?>
<form method="POST">
Id: <input type="text" name="id"/> <br/>
Name: <input type="text" name="name"/> <br/>
Price: <input type="text" name="price"/> <br/>
<input type="submit" value="Add"/>
</form>
<?php
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// set a query (all prices starting from 12)
$query->setQuery('price:[12 TO *]');
// set start and rows param (comparable to SQL limit) using fluent interface
$query->setStart(2)->setRows(20);
// set fields to fetch (this overrides the default setting 'all fields')
$query->setFields(array('id','name','price'));
// sort the results by price ascending
$query->addSort('price', Solarium_Query_Select::SORT_ASC);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// this is the custom result document class
class myDoc extends Solarium_Document_ReadOnly{
public function getSpecialPrice()
{
return round(($this->price * .95), 2);
}
}
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// set the custom resultclass
$query->setDocumentClass('myDoc');
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
// this method is added by the custom class
echo '<tr><th>offer price</th><td>' . $document->getSpecialPrice() . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// create a filterquery
$fq = $query->createFilterQuery();
$fq->setKey('maxprice');
$fq->setQuery('price:[1 TO 300]');
// add it to the query
$query->addFilterQuery($fq);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// get the facetset component
$facetSet = $query->getFacetSet();
// create a facet field instance and set options
$facet = $facetSet->createFacetField();
$facet->setKey('stock');
$facet->setField('inStock');
// add the facet instance to the facetset
$facetSet->addFacet($facet);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Facet counts for field "inStock":<br/>';
$facet = $resultset->getFacetSet()->getFacet('stock');
foreach($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// get the facetset component
$facetSet = $query->getFacetSet();
// create a facet query instance and set options
$facet = $facetSet->createFacetQuery();
$facet->setKey('stock');
$facet->setQuery('inStock: true');
// add the facet instance to the facetset
$facetSet->addFacet($facet);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet query count
$count = $resultset->getFacetSet()->getFacet('stock')->getValue();
echo '<hr/>Facet query count : ' . $count;
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// get the facetset component
$facetSet = $query->getFacetSet();
// create a facet query instance and set options
$facet = $facetSet->createFacetMultiQuery();
$facet->setKey('stock');
$facet->createQuery('stock_pricecat1', 'inStock:true AND price:[1 TO 300]');
$facet->createQuery('nostock_pricecat1', 'inStock:false AND price:[1 TO 300]');
$facet->createQuery('stock_pricecat2', 'inStock:true AND price:[300 TO *]');
$facet->createQuery('nostock_pricecat2', 'inStock:false AND price:[300 TO *]');
// add the facet instance to the facetset
$facetSet->addFacet($facet);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Multiquery facet counts:<br/>';
$facet = $resultset->getFacetSet()->getFacet('stock');
foreach($facet as $key => $count) {
echo $key . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// get the facetset component
$facetSet = $query->getFacetSet();
// create a facet field instance and set options
$facet = $facetSet->createFacetRange();
$facet->setKey('priceranges');
$facet->setField('price');
$facet->setStart(1);
$facet->setGap(100);
$facet->setEnd(1000);
// add the facet instance to the facetset
$facetSet->addFacet($facet);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Facet ranges:<br/>';
$facet = $resultset->getFacetSet()->getFacet('priceranges');
foreach($facet as $range => $count) {
echo $range . ' to ' . ($range + 100) . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// add a query and morelikethis settings (using fluent interface)
$query->setQuery('apache')
->getMoreLikeThis()
->setFields('manu,cat')
->setMinimumDocumentFrequency(1)
->setMinimumTermFrequency(1);
// this executes the query and returns the result
$resultset = $client->select($query);
$mlt = $resultset->getMoreLikeThis();
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table><br/><b>MLT results:</b><br/>';
// mlt results can be fetched by document id (the field defined as uniquekey in this schema)
$mltResult = $mlt->getResult($document->id);
if($mltResult){
echo 'Max score: '.$mltResult->getMaximumScore().'<br/>';
echo 'NumFound: '.$mltResult->getNumFound().'<br/>';
echo 'Num. fetched: '.count($mltResult).'<br/>';
foreach($mltResult AS $mltDoc) {
echo 'MLT result doc: '. $mltDoc->name . ' (id='. $mltDoc->id . ')<br/>';
}
}else{
echo 'No MLT results';
}
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
$query->setQuery('memory');
// get highlighting component and apply settings
$hl = $query->getHighlighting();
$hl->setFields('name, features');
$hl->setSimplePrefix('<b>');
$hl->setSimplePostfix('</b>');
// this executes the query and returns the result
$resultset = $client->select($query);
$highlighting = $resultset->getHighlighting();
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table><br/><b>Highlighting results:</b><br/>';
// highlighting results can be fetched by document id (the field defined as uniquekey in this schema)
$highlightedDoc = $highlighting->getResult($document->id);
if($highlightedDoc){
foreach($highlightedDoc as $field => $highlight) {
echo implode(' (...) ', $highlight) . '<br/>';
}
}
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// get the dismax component and set a boost query
$dismax = $query->getDisMax();
$dismax->setBoostQuery('cat:"graphics card"^2');
// this query is now a dismax query
$query->setQuery('memory -printer');
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance and a query helper instance
$query = $client->createSelect();
$helper = $query->getHelper();
// add a filterquery on a price range, using the helper to generate the range
$fqPrice = $query->createFilterQuery();
$fqPrice->setKey('price');
$fqPrice->setQuery($helper->rangeQuery('price', 10, 300));
$query->addFilterQuery($fqPrice);
// add a filterquery to find products in a range of 5km, using the helper to generate the 'geofilt' filter
$fqRegion = $query->createFilterQuery();
$fqRegion->setKey('region');
$fqRegion->setQuery($helper->geofilt(45.15, -93.85, 'store', 5));
$query->addFilterQuery($fqRegion);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a new document for the data
$doc1 = new Solarium_Document_ReadWrite();
$doc1->id = 123;
$doc1->name = 'testdoc-1';
$doc1->price = 364;
// and a second one
$doc2 = new Solarium_Document_ReadWrite();
$doc2->id = 124;
$doc2->name = 'testdoc-2';
$doc2->price = 340;
// create a client instance
$client = new Solarium_Client($config);
// get an update query instance
$update = $client->createUpdate();
// add the documents and a commit command to the update query
$update->addDocuments(array($doc1, $doc2));
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed<b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get an update query instance
$update = $client->createUpdate();
// add the delete query and a commit command to the update query
$update->addDeleteQuery('name:testdoc*');
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed<b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get an update query instance
$update = $client->createUpdate();
// add the delete id and a commit command to the update query
$update->addDeleteById(123);
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed<b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// apply settings using the API
$query->setQuery('*:*');
$query->setStart(2)->setRows(20);
$query->setFields(array('id','name','price'));
$query->addSort('price', Solarium_Query_Select::SORT_ASC);
// create a filterquery using the API
$fq = $query->createFilterQuery();
$fq->setKey('maxprice');
$fq->setQuery('price:[1 TO 300]');
// and add it to the query
$query->addFilterQuery($fq);
// create a facet field instance and set options using the API
$facetSet = $query->getFacetSet();
$facet = $facetSet->createFacetField();
$facet->setKey('stock');
$facet->setField('inStock');
$facetSet->addFacet($facet);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Facet counts for field "inStock":<br/>';
$facet = $resultset->getFacetSet()->getFacet('stock');
foreach($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// In this case an array is used for configuration to keep the example simple.
// For an easier to use config file you are probably better of with another format, like Zend_Config_Ini
// See the documentation for more info about this.
$select = array(
'query' => '*:*',
'start' => 2,
'rows' => 20,
'fields' => array('id','name','price'),
'sort' => array('price' => 'asc'),
'filterquery' => array(
'maxprice' => array(
'query' => 'price:[1 TO 300]'
),
),
'component' => array(
'facetset' => array(
'facet' => array(
// notice this config uses an inline key value, instead of array key like the filterquery
array('type' => 'field', 'key' => 'stock', 'field' => 'inStock'),
)
),
),
);
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance based on the config
$query = $client->createSelect($select);
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Facet counts for field "inStock":<br/>';
$facet = $resultset->getFacetSet()->getFacet('stock');
foreach($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// In most cases using the API or config is advisable, however in some cases it can make sense to extend classes.
// This makes it possible to create 'query inheritance' like in this example
class ProductQuery extends Solarium_Query_Select{
protected function _init()
{
parent::_init();
// basic params
$this->setQuery('*:*');
$this->setStart(2)->setRows(20);
$this->setFields(array('id','name','price'));
$this->addSort('price', Solarium_Query_Select::SORT_ASC);
// create a facet field instance and set options
$facetSet = $this->getFacetSet();
$facet = $facetSet->createFacetField();
$facet->setKey('stock');
$facet->setField('inStock');
$facetSet->addFacet($facet);
}
}
// This query inherits all of the query params of it's parent (using parent::_init) and adds some more
// Ofcourse it could also alter or remove settings
class ProductPriceLimitedQuery extends ProductQuery{
protected function _init()
{
parent::_init();
// create a filterquery
$fq = $this->createFilterQuery();
$fq->setKey('maxprice');
$fq->setQuery('price:[1 TO 300]');
// and add it
$this->addFilterQuery($fq);
}
}
// create a client instance
$client = new Solarium_Client($config);
// create a query instance
$query = new ProductPriceLimitedQuery;
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// display facet counts
echo '<hr/>Facet counts for field "inStock":<br/>';
$facet = $resultset->getFacetSet()->getFacet('stock');
foreach($facet as $value => $count) {
echo $value . ' [' . $count . ']<br/>';
}
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
echo '<tr><th>id</th><td>' . $document->id . '</td></tr>';
echo '<tr><th>name</th><td>' . $document->name . '</td></tr>';
echo '<tr><th>price</th><td>' . $document->price . '</td></tr>';
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// This example shows how to manually execute the query flow.
// By doing this manually you can customize data in between any step (although a plugin might be better for this)
// And you can use only a part of the flow. You could for instance use the query object and request builder,
// but execute the request in your own code.
// create a client instance
$client = new Solarium_Client($config);
// create a select query instance
$query = $client->createSelect();
// manually create a request for the query
$request = $client->createRequest($query);
// you can now use the request object for getting an uri (ie. to use in you own code)
// or you could modify the request object
echo 'Request URI: ' . $request->getUri() . '<br/>';
// you can still execute the request using the client and get a 'raw' response object
$response = $client->executeRequest($request);
// and finally you can convert the response into a result
$result = $client->createResult($query, $response);
// display the total number of documents found by solr
echo 'NumFound: '.$result->getNumFound();
// show documents using the resultset iterator
foreach ($result as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// This is a custom query class that could have some customized logic
class MyQuery extends Solarium_Query_Select
{
// ...customization here...
}
// And this is the extended client, that modifies the default query mapping
// for select queries to our custom query class.
// BTW, the same could also be done using a plugin, see example 5.3.2
class MyClient extends Solarium_Client
{
/**
* Querytype mappings
*/
protected $_queryTypes = array(
self::QUERYTYPE_SELECT => array(
'query' => 'MyQuery',
'requestbuilder' => 'Solarium_Client_RequestBuilder_Select',
'responseparser' => 'Solarium_Client_ResponseParser_Select'
),
self::QUERYTYPE_UPDATE => array(
'query' => 'Solarium_Query_Update',
'requestbuilder' => 'Solarium_Client_RequestBuilder_Update',
'responseparser' => 'Solarium_Client_ResponseParser_Update'
),
self::QUERYTYPE_PING => array(
'query' => 'Solarium_Query_Ping',
'requestbuilder' => 'Solarium_Client_RequestBuilder_Ping',
'responseparser' => 'Solarium_Client_ResponseParser_Ping'
),
);
}
// create a client instance
$client = new MyClient($config);
// create a select query instance
$query = $client->createSelect();
// check the query class, it should be our custom query class
echo 'Query class: ' . get_class($query) . '<br/>';
// execute query
$result = $client->execute($query);
// display the total number of documents found by solr
echo 'NumFound: '.$result->getNumFound();
// show documents using the resultset iterator
foreach ($result as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
// this very simple plugin shows a timing for each event and display some request debug info
class basicDebug extends Solarium_Plugin_Abstract
{
protected $_start;
protected $_output = array();
public function _initPlugin()
{
$this->_start = microtime(true);
}
protected function _timer($event)
{
$time = round(microtime(true) - $this->_start, 5);
$this->_output[] = '['.$time.'] ' . $event;
}
public function display()
{
echo implode('<br/>', $this->_output);
}
public function preCreateRequest()
{
$this->_timer('preCreateRequest');
}
public function postCreateRequest()
{
$this->_timer('postCreateRequest');
}
// This method uses the aviable param(s) (see plugin abstract class)
// You can access or modify data this way
public function preExecuteRequest($request)
{
$this->_timer('preExecuteRequest');
// this dummy param will be visible in the debug output but will also be used in the actual Solr request
$request->addParam('dummyparam', 'dummyvalue');
$this->_output[] = 'Request URI: ' . $request->getUri();
}
public function postExecuteRequest()
{
$this->_timer('postExecuteRequest');
}
public function preCreateResult()
{
$this->_timer('preCreateResult');
}
public function postCreateResult()
{
$this->_timer('postCreateResult');
}
public function preExecute()
{
$this->_timer('preExecute');
}
public function postExecute()
{
$this->_timer('postExecute');
}
public function preCreateQuery()
{
$this->_timer('preCreateResult');
}
public function postCreateQuery()
{
$this->_timer('postCreateResult');
}
}
htmlHeader();
// create a client instance and register the plugin
$plugin = new basicDebug();
$client = new Solarium_Client($config);
$client->registerPlugin('debugger', $plugin);
// execute a select query and display the results
$query = $client->createSelect();
$resultset = $client->select($query);
echo 'NumFound: '.$resultset->getNumFound();
foreach ($resultset as $document) {
echo '<hr/><table>';
foreach($document AS $field => $value)
{
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
// display the debug plugin output
echo '<hr/><h1>Plugin output</h1>';
$plugin->display();
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
// This is a custom query class that could have some customized logic
class MyQuery extends Solarium_Query_Select
{
// ...customization here...
}
// this very simple plugin that modifies the default querytype mapping
class queryCustomizer extends Solarium_Plugin_Abstract
{
protected function _initPlugin()
{
$this->_client->registerQueryType(
Solarium_Client::QUERYTYPE_SELECT,
'MyQuery',
'Solarium_Client_RequestBuilder_Select',
'Solarium_Client_ResponseParser_Select'
);
}
}
htmlHeader();
// create a client instance and register the plugin
$client = new Solarium_Client($config);
$client->registerPlugin('querycustomizer', 'queryCustomizer');
// create a select query instance
$query = $client->createSelect();
// check the query class, it should be our custom query class
echo 'Query class: ' . get_class($query) . '<br/>';
// execute the query and display the results
$resultset = $client->select($query);
echo 'NumFound: '.$resultset->getNumFound();
foreach ($resultset as $document) {
echo '<hr/><table>';
foreach($document AS $field => $value)
{
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to zendhttp and get a zendhttp client instance reference
$client->setAdapter('Solarium_Client_Adapter_ZendHttp');
$zendHttp = $client->getAdapter()->getZendHttp();
// you can use any of the zend_http features, like http-authentication
$zendHttp->setAuth('user', 'password!', Zend_Http_Client::AUTH_BASIC);
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// get a select query instance
$query = $client->createSelect();
// search input string, this value fails without escaping because of the double-quote
$input = 'ATA "133';
// in this case phrase escaping is used (most common) but you can also do term escaping, see the manual
$query->setQuery('features:' . Solarium_Escape::phrase($input));
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach($document AS $field => $value)
{
// this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
\ No newline at end of file
<?php
require('init.php');
htmlHeader();
echo 'TODO';
htmlFooter();
\ No newline at end of file
<?php
$config = array(
'adapteroptions' => array(
'host' => '127.0.0.1',
'port' => 8983,
'path' => '/solr/',
)
);
<html>
<head>
<title>Solarium examples</title>
</head>
<body>
<h1>Solarium examples</h1>
<p>
In this folder you can find various examples for the Solarium PHP Solr client library, to be used on a Solr 'example' index as distributed with Solr.<br/>
Only the code is included, for more details about the examples and how to get them working please see the manual on the project website: <a href="http://www.solarium-project.org" target="_blank">http://www.solarium-project.org</a>
</p>
<p>
If examples for some Solarium functionality are missing please request them by opening an issue in the issue tracker: <a href="http://github.com/basdenooijer/solarium/issues" target="_blank">http://github.com/basdenooijer/solarium/issues</a>
</p>
<p>
<b>Important:</b> This code is intended to demonstrate the usage of Solarium. It is not intended for real-world use. For instance user input validation is missing or very limited, as the best way to do this will depend on your application and is not Solarium functionality.<br>
It's advised not to deploy the examples to a public environment, or at least make sure the example directory is not available via your webserver.
</p>
<ul style="list-style:none;">
<li>1. Basic usage</li>
<ul style="list-style:none;">
<li><a href="1.1-check-solarium-and-ping.php">1.1 Check solarium availability and ping Solr</a></li>
<li><a href="1.2-basic-select.php">1.2 Basic select</a></li>
<li><a href="1.3-basic-update.php">1.3 Basic update - add document</a></li>
</ul>
<li>2. Select query</li>
<ul style="list-style:none;">
<li><a href="2.1-query-params.php">2.1 Select query params</a></li>
<li><a href="2.2-custom-result-document.php">2.2 Custom result document</a></li>
<li><a href="2.3-filterquery.php">2.3 Filterquery</a></li>
<li>2.4 Components</li>
<ul style="list-style:none;">
<li>2.5.1 FacetSet</li>
<ul style="list-style:none;">
<li><a href="2.5.1.1-facet-field.php">2.5.1.1 Facet field</a></li>
<li><a href="2.5.1.2-facet-query.php">2.5.1.2 Facet query</a></li>
<li><a href="2.5.1.3-facet-multiquery.php">2.5.1.3 Facet multiquery</a></li>
<li><a href="2.5.1.4-facet-range.php">2.5.1.4 Facet range</a></li>
</ul>
<li><a href="2.5.2-morelikethis.php">2.5.2 MoreLikeThis</a></li>
<li><a href="2.5.3-highlighting.php">2.5.3 Highlighting</a></li>
<li><a href="2.5.4-dismax.php">2.5.4 Dismax</a></li>
</ul>
<li><a href="2.6-helper-functions.php">2.6 Helper functions</a></li>
</ul>
<li>3. Update query</li>
<ul style="list-style:none;">
<li><a href="3.1-add-docs.php">3.1 Add docs</a></li>
<li><a href="3.2-delete-by-query.php">3.2 Delete by query</a></li>
<li><a href="3.3-delete-by-id.php">3.3 Delete by ID</a></li>
</ul>
<li>4. Usage modes</li>
<ul style="list-style:none;">
<li><a href="4.1-api-usage.php">4.1 API</a></li>
<li><a href="4.2-configuration-usage.php">4.2 Configuration</a></li>
<li><a href="4.3-extending-usage.php">4.3 Extending</a></li>
</ul>
<li>5. Customization</li>
<ul style="list-style:none;">
<li><a href="5.1-partial-usage.php">5.1 Partial usage</a></li>
<li><a href="5.2-extending.php">5.2 Extending</a></li>
<li>5.3 Plugin system</li>
<ul style="list-style:none;">
<li><a href="5.3.1-plugin-event-hooks.php">5.3.1 Event hooks</a></li>
<li><a href="5.3.2-plugin-solarium-presets.php">5.3.2 Modifying Solarium presets</a></li>
</ul>
</ul>
<li>6. Miscellaneous</li>
<ul style="list-style:none;">
<li><a href="6.1-zend-http-adapter.php">6.1 Zend_Http adapter</a></li>
<li><a href="6.2-escaping.php">6.2 Escaping</a></li>
<li><a href="6.3-demo-app.php">2.7 Demo search (mini) application</a></li>
</ul>
</ul>
</body>
</html>
\ No newline at end of file
<?php
error_reporting(E_ALL);
ini_set('display_errors', true);
require('../library/Solarium/Autoloader.php');
Solarium_Autoloader::register();
if (file_exists('config.php')) {
require('config.php');
} else {
require('config.dist.php');
}
function htmlHeader(){
echo '<html><head><title>Solarium examples</title></head><body>';
}
function htmlFooter(){
echo '</body></html>';
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......@@ -39,7 +40,7 @@
*
* This class is included to allow for easy usage of Solarium. If you already
* have your own autoloader that follows the Zend Framework class/file naming
* you don't need this.
* you can use that to autoload Solarium (for instance Zend_Loader).
*
* @package Solarium
*/
......
......@@ -31,6 +31,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......@@ -39,14 +40,15 @@
/**
* Main interface for interaction with Solr
*
* The client holds the Solr connection settings and uses an adapter instance to
* execute queries and return the results. This is the main interface for any
* user of the Solarium library.
* The client is the main interface for usage of the Solarium library.
* You can use it to get query instances and to execute them.
* It also allows to register plugins and querytypes to customize Solarium.
* Finally, it also gives access to the adapter, which holds the Solr connection settings.
*
* Example usage with default settings:
* <code>
* $client = new Solarium_Client;
* $query = new Solarium_Query_Select;
* $query = $client->createSelect();
* $result = $client->select($query);
* </code>
*
......@@ -66,9 +68,6 @@ class Solarium_Client extends Solarium_Configurable
/**
* Default options
*
* The defaults match a standard Solr example instance as distributed by
* the Apache Lucene Solr project.
*
* @var array
*/
protected $_options = array(
......@@ -77,6 +76,8 @@ class Solarium_Client extends Solarium_Configurable
/**
* Querytype mappings
*
* These can be customized using {@link registerQueryType()}
*/
protected $_queryTypes = array(
self::QUERYTYPE_SELECT => array(
......@@ -220,7 +221,9 @@ class Solarium_Client extends Solarium_Configurable
/**
* Register a querytype
*
* You can also use this method to override any existing querytype with a new mapping
* You can also use this method to override any existing querytype with a new mapping.
* This requires the availability of the classes through autoloading or a manual
* require before calling this method.
*
* @param string $type
* @param string $query
......@@ -273,8 +276,12 @@ class Solarium_Client extends Solarium_Configurable
/**
* Register a plugin
*
* You can supply a plugin instance or a plugin classname as string.
* This requires the availability of the class through autoloading
* or a manual require.
*
* @param string $key
* @param string|object $plugin
* @param string|Solarium_Plugin_Abstract $plugin
* @param array $options
* @return Solarium_Client Provides fluent interface
*/
......@@ -287,7 +294,7 @@ class Solarium_Client extends Solarium_Configurable
if (!($plugin instanceof Solarium_Plugin_Abstract)) {
throw new Solarium_Exception('All plugins must extend Solarium_Plugin_Abstract');
}
$plugin->init($this, $options);
$this->_plugins[$key] = $plugin;
......@@ -331,7 +338,7 @@ class Solarium_Client extends Solarium_Configurable
* Get a plugin instance
*
* @param string $key
* @return array|null
* @return Solarium_Plugin_Abstract|null
*/
public function getPlugin($key)
{
......@@ -378,8 +385,6 @@ class Solarium_Client extends Solarium_Configurable
/**
* Creates a request based on a query instance
*
* @todo add caching of request builder?
*
* @param Solarium_Query $query
* @return Solarium_Client_Request
*/
......@@ -468,7 +473,7 @@ class Solarium_Client extends Solarium_Configurable
* Example usage:
* <code>
* $client = new Solarium_Client;
* $query = new Solarium_Query_Ping;
* $query = $client->createPing();
* $result = $client->ping($query);
* </code>
*
......@@ -478,7 +483,7 @@ class Solarium_Client extends Solarium_Configurable
* execute method, thus allowing for an easy to use and clean API.
*
* @param Solarium_Query_Ping $query
* @return boolean
* @return Solarium_Result_Ping
*/
public function ping($query)
{
......@@ -491,9 +496,9 @@ class Solarium_Client extends Solarium_Configurable
* Example usage:
* <code>
* $client = new Solarium_Client;
* $update = new Solarium_Query_Update;
* $query = $client->createUpdate();
* $update->addOptimize();
* $result = $client->ping($update);
* $result = $client->update($update);
* </code>
*
* @see Solarium_Query_Update
......@@ -516,8 +521,8 @@ class Solarium_Client extends Solarium_Configurable
* Example usage:
* <code>
* $client = new Solarium_Client;
* $query = new Solarium_Query_Select;
* $result = $client->ping($query);
* $query = $client->createSelect();
* $result = $client->select($query);
* </code>
*
* @see Solarium_Query_Select
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......@@ -42,8 +43,7 @@
* configuration options. For more info see the manual at
* {@link http://framework.zend.com/manual/en/zend.http.html}
*
* To use this adapter you need to have the Zend Framework in your include path,
* autoloader or manually included.
* To use this adapter you need to have the Zend Framework available (autoloading)
*
* @package Solarium
* @subpackage Client
......@@ -172,7 +172,10 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
$data = $response->getBody();
}
return new Solarium_Client_Response($data, $response->getHeaders());
// this is used because getHeaders doesn't return the HTTP header...
$headers = explode("\n",$response->getHeadersAsString());
return new Solarium_Client_Response($data, $headers);
}
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......@@ -54,7 +55,7 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
public function build($component, $request)
{
// enable highlighting
$request->addParam('hl', true);
$request->addParam('hl','true');
$request->addParam('hl.fl', $component->getFields());
$request->addParam('hl.snippets', $component->getSnippets());
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......@@ -54,7 +55,7 @@ class Solarium_Client_RequestBuilder_Select_Component_MoreLikeThis
public function build($component, $request)
{
// enable morelikethis
$request->addParam('mlt', true);
$request->addParam('mlt', 'true');
$request->addParam('mlt.fl', $component->getFields());
$request->addParam('mlt.mintf', $component->getMinimumTermFrequency());
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Client
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Document
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Document
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......@@ -63,22 +64,24 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
$this->_client = $client;
parent::__construct($options);
$this->_init();
$this->_initPlugin();
}
/**
* Secondary init function
* Plugin init function
*
* This is an extension point for plugin implemenations
* This is an extension point for plugin implemenations.
* Will be called as soon as $this->_client and options have been set.
*
* @return void
*/
public function _init()
protected function _initPlugin()
{
}
/**
* preCreateRequest hook
*
* @param Solarium_Query $query
* @return void|Solarium_Client_Request
......@@ -88,6 +91,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* postCreateRequest hook
*
* @param Solarium_Query $query
* @param Solarium_Client_Request $request
* @return void
......@@ -97,6 +102,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* preExecuteRequest hook
*
* @param Solarium_Client_Request $request
* @return void|Solarium_Client_Response
*/
......@@ -105,6 +112,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* postExecuteRequest hook
*
* @param Solarium_Client_Request $request
* @param Solarium_Client_Response $response
* @return void
......@@ -114,6 +123,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* preCreateResult hook
*
* @param Solarium_Query $query
* @param Solarium_Client_Response $response
* @return void|Solarium_Result
......@@ -123,6 +134,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* postCreateResult hook
*
* @param Solarium_Query $query
* @param Solarium_Client_Response $response
* @param Solarium_Result $result
......@@ -133,6 +146,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* preExecute hook
*
* @param Solarium_Query $query
* @return void|Solarium_Result
*/
......@@ -141,6 +156,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* postExecute hook
*
* @param Solarium_Query $query
* @param Solarium_Result $result
* @return void
......@@ -150,6 +167,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* preCreateQuery hook
*
* @param string $query
* @param mixed $options
* @return void|Solarium_Query
......@@ -159,6 +178,8 @@ abstract class Solarium_Plugin_Abstract extends Solarium_Configurable
}
/**
* postCreateQuery hook
*
* @param string $query
* @param mixed $options
* @param Solarium_Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......@@ -64,6 +65,7 @@ class Solarium_Query_Ping extends Solarium_Query
* @var array
*/
protected $_options = array(
'resultclass' => 'Solarium_Result_Ping',
'handler' => 'admin/ping',
);
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......@@ -194,7 +195,7 @@ class Solarium_Query_Select extends Solarium_Query
* escaping of user input.
*
* @param string $query
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setQuery($query)
{
......@@ -215,7 +216,7 @@ class Solarium_Query_Select extends Solarium_Query
* Set the start offset
*
* @param integer $start
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setStart($start)
{
......@@ -236,7 +237,7 @@ class Solarium_Query_Select extends Solarium_Query
* Set a custom resultclass
*
* @param string $value classname
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setResultClass($value)
{
......@@ -282,7 +283,7 @@ class Solarium_Query_Select extends Solarium_Query
* Set the number of rows to fetch
*
* @param integer $rows
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setRows($rows)
{
......@@ -303,7 +304,7 @@ class Solarium_Query_Select extends Solarium_Query
* Specify a field to return in the resultset
*
* @param string $field
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addField($field)
{
......@@ -317,7 +318,7 @@ class Solarium_Query_Select extends Solarium_Query
* @param string|array $fields can be an array or string with comma
* separated fieldnames
*
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addFields($fields)
{
......@@ -337,7 +338,7 @@ class Solarium_Query_Select extends Solarium_Query
* Remove a field from the field list
*
* @param string $field
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function removeField($field)
{
......@@ -351,7 +352,7 @@ class Solarium_Query_Select extends Solarium_Query
/**
* Remove all fields from the field list.
*
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function clearFields()
{
......@@ -375,7 +376,7 @@ class Solarium_Query_Select extends Solarium_Query
* This overwrites any existing fields
*
* @param array $fields
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setFields($fields)
{
......@@ -390,7 +391,7 @@ class Solarium_Query_Select extends Solarium_Query
*
* @param string $sort
* @param string $order
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addSort($sort, $order)
{
......@@ -405,7 +406,7 @@ class Solarium_Query_Select extends Solarium_Query
* The input array must contain sort items as keys and the order as values.
*
* @param array $sorts
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addSorts(array $sorts)
{
......@@ -420,7 +421,7 @@ class Solarium_Query_Select extends Solarium_Query
* Remove a sort
*
* @param string $sort
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function removeSort($sort)
{
......@@ -434,7 +435,7 @@ class Solarium_Query_Select extends Solarium_Query
/**
* Remove all sorts
*
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function clearSorts()
{
......@@ -458,7 +459,7 @@ class Solarium_Query_Select extends Solarium_Query
* This overwrites any existing sorts
*
* @param array $sorts
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function setSorts($sorts)
{
......@@ -486,7 +487,7 @@ class Solarium_Query_Select extends Solarium_Query
* filterquery instance wil be created based on the options.
*
* @param Solarium_Query_Select_FilterQuery|array $filterQuery
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addFilterQuery($filterQuery)
{
......@@ -513,7 +514,7 @@ class Solarium_Query_Select extends Solarium_Query
* Add multiple filterqueries
*
* @param array $filterQueries
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function addFilterQueries(array $filterQueries)
{
......@@ -559,7 +560,7 @@ class Solarium_Query_Select extends Solarium_Query
* Remove a single filterquery by key
*
* @param string $key
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function removeFilterQuery($key)
{
......@@ -573,7 +574,7 @@ class Solarium_Query_Select extends Solarium_Query
/**
* Remove all filterqueries
*
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function clearFilterQueries()
{
......@@ -611,7 +612,7 @@ class Solarium_Query_Select extends Solarium_Query
* @param string $component
* @param string $requestBuilder
* @param string $responseParser
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
public function registerComponentType($key, $component, $requestBuilder=null, $responseParser=null)
{
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......@@ -61,7 +62,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* specified or blank.
*
* @param string $queryAlternative
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setQueryAlternative($queryAlternative)
{
......@@ -87,7 +88,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* The format supported is "fieldOne^2.3 fieldTwo fieldThree^0.4"
*
* @param string $queryFields
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setQueryFields($queryFields)
{
......@@ -111,7 +112,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* clauses must match. See Solr manual for details.
*
* @param string $minimumMatch
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setMinimumMatch($minimumMatch)
{
......@@ -137,7 +138,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* Format is: "fieldA^1.0 fieldB^2.2"
*
* @param string $phraseFields
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setPhraseFields($phraseFields)
{
......@@ -161,7 +162,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* (affects boosting)
*
* @param string $phraseSlop
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setPhraseSlop($phraseSlop)
{
......@@ -185,7 +186,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* query string (in qf fields; affects matching)
*
* @param string $queryPhraseSlop
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setQueryPhraseSlop($queryPhraseSlop)
{
......@@ -208,7 +209,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* Float value to use as tiebreaker in DisjunctionMaxQueries
*
* @param float $tie
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setTie($tie)
{
......@@ -232,7 +233,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* with the user's query to influence the score.
*
* @param string $boostQuery
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setBoostQuery($boostQuery)
{
......@@ -258,7 +259,7 @@ class Solarium_Query_Select_Component_DisMax extends Solarium_Query_Select_Compo
* Format is: "funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2"
*
* @param string $boostFunctions
* @return Solarium_Query_Component_DisMax Provides fluent interface
* @return Solarium_Query_Select_Component_DisMax Provides fluent interface
*/
public function setBoostFunctions($boostFunctions)
{
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......@@ -66,7 +67,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Separate multiple fields with commas.
*
* @param string $fields
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFields($fields)
{
......@@ -89,7 +90,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Maximum number of snippets per field
*
* @param int $maximum
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setSnippets($maximum)
{
......@@ -112,7 +113,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* The size, in characters, of fragments to consider for highlighting
*
* @param int $size
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFragSize($size)
{
......@@ -135,7 +136,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Collapse contiguous fragments into a single fragment
*
* @param boolean $merge
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setMergeContiguous($merge)
{
......@@ -156,7 +157,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set requireFieldMatch option
*
* @param boolean $require
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setRequireFieldMatch($require)
{
......@@ -179,7 +180,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* How many characters into a document to look for suitable snippets
*
* @param int $chars
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setMaxAnalyzedChars($chars)
{
......@@ -200,7 +201,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set alternatefield option
*
* @param string $field
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setAlternateField($field)
{
......@@ -221,7 +222,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set maxAlternateFieldLength option
*
* @param int $length
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setMaxAlternateFieldLength($length)
{
......@@ -242,7 +243,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set formatter option
*
* @param string $formatter
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFormatter($formatter = 'simple')
{
......@@ -265,7 +266,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Solr option h1.simple.pre
*
* @param string $prefix
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setSimplePrefix($prefix)
{
......@@ -290,7 +291,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Solr option h1.simple.post
*
* @param string $postfix
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setSimplePostfix($postfix)
{
......@@ -315,7 +316,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Use one of the constants as value.
*
* @param string $fragmenter
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFragmenter($fragmenter)
{
......@@ -336,7 +337,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set fraglistbuilder option
*
* @param string $builder
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFragListBuilder($builder)
{
......@@ -357,7 +358,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set fragmentsbuilder option
*
* @param string $builder
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setFragmentsBuilder($builder)
{
......@@ -378,7 +379,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set useFastVectorHighlighter option
*
* @param boolean $use
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setUseFastVectorHighlighter($use)
{
......@@ -399,7 +400,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set usePhraseHighlighter option
*
* @param boolean $use
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setUsePhraseHighlighter($use)
{
......@@ -420,7 +421,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set HighlightMultiTerm option
*
* @param boolean $highlight
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setHighlightMultiTerm($highlight)
{
......@@ -441,7 +442,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set RegexSlop option
*
* @param float $slop
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setRegexSlop($slop)
{
......@@ -462,7 +463,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set RegexPattern option
*
* @param string $pattern
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setRegexPattern($pattern)
{
......@@ -483,7 +484,7 @@ class Solarium_Query_Select_Component_Highlighting extends Solarium_Query_Select
* Set RegexMaxAnalyzedChars option
*
* @param int $chars
* @return Solarium_Query_Component_Highlighting Provides fluent interface
* @return Solarium_Query_Select_Component_Highlighting Provides fluent interface
*/
public function setRegexMaxAnalyzedChars($chars)
{
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......@@ -62,7 +63,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* Separate multiple fields with commas.
*
* @param string $fields
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setFields($fields)
{
......@@ -86,7 +87,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* in the source doc.
*
* @param int $minimum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMinimumTermFrequency($minimum)
{
......@@ -110,7 +111,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* ignored which do not occur in at least this many docs.
*
* @param int $minimum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMinimumDocumentFrequency($minimum)
{
......@@ -133,7 +134,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* Minimum word length below which words will be ignored.
*
* @param int $minimum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMinimumWordLength($minimum)
{
......@@ -156,7 +157,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* Maximum word length above which words will be ignored.
*
* @param int $maximum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMaximumWordLength($maximum)
{
......@@ -180,7 +181,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* query.
*
* @param int $maximum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMaximumQueryTerms($maximum)
{
......@@ -204,7 +205,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* stored with TermVector support.
*
* @param int $maximum
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setMaximumNumberOfTokens($maximum)
{
......@@ -227,7 +228,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* If true the query will be boosted by the interesting term relevance.
*
* @param boolean $boost
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setBoost($boost)
{
......@@ -253,7 +254,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* Separate multiple fields with commas.
*
* @param string $queryFields
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setQueryFields($queryFields)
{
......@@ -276,7 +277,7 @@ class Solarium_Query_Select_Component_MoreLikeThis extends Solarium_Query_Select
* The number of similar documents to return for each result
*
* @param int $count
* @return Solarium_Query_Component_MoreLikeThis Provides fluent interface
* @return Solarium_Query_Select_Component_MoreLikeThis Provides fluent interface
*/
public function setCount($count)
{
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Query
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......@@ -57,7 +58,7 @@ class Solarium_Result
/**
* Decode response data
*
* This is lazy loaded, see getData()
* This is lazy loaded, {@link getData()}
*
* @var array
*/
......
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
*/
/**
* Ping query result
*
* A ping query has no useful result (other than being succesful) so this class has no api
*
* @package Solarium
* @subpackage Result
*/
class Solarium_Result_Ping
{
}
\ No newline at end of file
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......@@ -214,7 +215,7 @@ class Solarium_Result_Select extends Solarium_Result_QueryType
*
* This is a convenience method that maps presets to getComponent
*
* @return Solarium_Result_Select_Component_MoreLikeThis
* @return Solarium_Result_Select_MoreLikeThis
*/
public function getMoreLikeThis()
{
......@@ -226,7 +227,7 @@ class Solarium_Result_Select extends Solarium_Result_QueryType
*
* This is a convenience method that maps presets to getComponent
*
* @return Solarium_Result_Select_Component_Highlighting
* @return Solarium_Result_Select_Highlighting
*/
public function getHighlighting()
{
......@@ -238,7 +239,7 @@ class Solarium_Result_Select extends Solarium_Result_QueryType
*
* This is a convenience method that maps presets to getComponent
*
* @return Solarium_Result_Select_Component_FacetSet
* @return Solarium_Result_Select_FacetSet
*/
public function getFacetSet()
{
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
* @subpackage Result
......
......@@ -30,6 +30,7 @@
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*
* @package Solarium
*/
......
......@@ -59,11 +59,21 @@ class Solarium_Client_Adapter_HttpTest extends PHPUnit_Framework_TestCase
public function testExecuteErrorResponse()
{
$data = 'test123';
$request = new Solarium_Client_Request();
$this->setExpectedException('Solarium_Client_HttpException');
$this->_adapter->execute($request);
$mock = $this->getMock('Solarium_Client_Adapter_Http', array('_getData','check'));
$mock->expects($this->once())
->method('_getData')
->with($this->equalTo('http://127.0.0.1:8983/solr/?'), $this->isType('resource'))
->will($this->returnValue(array($data, array('HTTP 1.1 200 OK'))));
$mock->expects($this->once())
->method('check')
->will($this->throwException(new Solarium_Client_HttpException("HTTP request failed")));
$this->setExpectedException('Solarium_Client_HttpException');
$mock->execute($request);
}
public function testCheckError()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment