/** Get the latest records back from solr
  *
  */
 public function latestRecordsPublications($q = '*:*', $fields = 'id,old_findID,objecttype,imagedir,filename,thumbnail,broadperiod,workflow', $start = 0, $limit = 4, $sort = 'id', $direction = 'desc')
 {
     $select = array('query' => $q, 'start' => $start, 'rows' => $limit, 'fields' => array($fields), 'sort' => array($sort => $direction), 'filterquery' => array());
     if (!in_array($this->getRole(), $this->_allowed)) {
         $select['filterquery']['workflow'] = array('query' => 'workflow:[3 TO 4]');
     }
     $select['filterquery']['images'] = array('query' => 'thumbnail:[1 TO *]');
     $cachekey = md5($q . $this->getRole() . 'biblio');
     if (!$this->_cache->test($cachekey)) {
         $query = $this->_solr->createSelect($select);
         $resultset = $this->_solr->select($query);
         $data = array();
         $data['numberFound'] = $resultset->getNumFound();
         foreach ($resultset as $doc) {
             $fields = array();
             foreach ($doc as $key => $value) {
                 $fields[$key] = $value;
             }
             $data['images'][] = $fields;
         }
         $this->_cache->save($data);
     } else {
         $data = $this->_cache->load($cachekey);
     }
     return $this->buildHtml($data);
 }
 /** Get the solr data
  * @access public
  * @return array
  */
 public function getSolrResults()
 {
     $query = $this->_solr->createSelect();
     $query->setRows(0);
     $stats = $query->getStats();
     $stats->createField('quantity');
     $resultset = $this->_solr->select($query);
     $data = $resultset->getStats();
     $stats = array();
     // Create array of data for use in partial
     foreach ($data as $result) {
         $stats['total'] = $result->getSum();
         $stats['records'] = $result->getCount();
     }
     return $stats;
 }
 /** Display of publications with filtration
  */
 public function indexAction()
 {
     $limit = 20;
     $page = $this->_getParam('page');
     if (!isset($page)) {
         $start = 0;
     } else {
         unset($params['page']);
         $start = ($page - 1) * 20;
     }
     $config = array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beopublications'));
     $select = array('query' => '*:*', 'start' => $start, 'rows' => $limit, 'fields' => array('*'), 'sort' => array('title' => 'asc'), 'filterquery' => array());
     $client = new Solarium_Client($config);
     // get a select query instance based on the config
     $query = $client->createSelect($select);
     $resultset = $client->select($query);
     $data = NULL;
     foreach ($resultset as $doc) {
         foreach ($doc as $key => $value) {
             $fields[$key] = $value;
         }
         $data[] = $fields;
     }
     $paginator = Zend_Paginator::factory($resultset->getNumFound());
     $paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit)->setPageRange(20);
     $this->view->paginator = $paginator;
     $this->view->results = $data;
 }
Example #4
0
 protected function getIds()
 {
     $client = new Solarium_Client($this->CONFIG);
     $select = $client->createSelect();
     $select->setRows(20000);
     $select->createFilterQuery('users')->setQuery('activeusers:[0 TO *]');
     $select->createFilterQuery('pages')->setQuery('wikipages:[500 TO *]');
     $select->createFilterQuery('words')->setQuery('words:[10 TO *]');
     $select->createFilterQuery('ns')->setQuery('ns:0');
     $select->createFilterQuery('wam')->setQuery('-(wam:0)');
     $select->createFilterQuery('dis')->setQuery('-(title_en:disambiguation)');
     $select->createFilterQuery('answer_host')->setQuery('-(host:*answers.wikia.com)');
     $select->createFilterQuery('answer')->setQuery('-(hub:Wikianswers)');
     //speedydeletion: 547090, scratchpad: 95, lyrics:43339, colors:32379
     $select->createFilterQuery('banned')->setQuery('-(wid:547090) AND -(wid:95) AND -(wid:43339) AND -(wid:32379)');
     // faceting would be less expensive
     $select->addParam('group', 'true');
     $select->addParam('group.field', 'wid');
     $select->addParam('group.ngroups', 'true');
     $result = $client->select($select);
     $ids = [];
     if (isset($result->getData()['grouped']['wid']['groups'])) {
         foreach ($result->getData()['grouped']['wid']['groups'] as $group) {
             $ids[] = $group['groupValue'];
         }
     }
     return $ids;
 }
Example #5
0
 /** Get records from solr
  * @access public
  * @return array
  */
 public function getRecords($cursor = 0, $set, $from, $until)
 {
     $fields = array('id', 'old_findID', 'creator', 'description', 'broadperiod', 'thumbnail', 'imagedir', 'filename', 'created', 'institution', 'updated', 'objecttype', 'fourFigure', 'fromdate', 'todate', 'county', 'district', 'materialTerm', 'knownas', 'secondaryMaterialTerm', 'fourFigureLat', 'fourFigureLon');
     $select = array('query' => '*:*', 'start' => $cursor, 'rows' => self::LISTLIMIT, 'fields' => $fields, 'sort' => array('created' => 'asc'), 'filterquery' => array());
     if (!in_array($this->getRole(), $this->_allowed)) {
         $select['filterquery']['workflow'] = array('query' => 'workflow:[3 TO 4]');
     }
     if (isset($set)) {
         $select['filterquery']['set'] = array('query' => 'institution:' . $set);
     }
     if (isset($from)) {
         $select['filterquery']['from'] = array('query' => 'created:[' . $this->todatestamp($from) . ' TO * ]');
     }
     if (isset($until)) {
         $select['filterquery']['until'] = array('query' => 'created:[* TO ' . $this->todatestamp($until) . ']');
     }
     $query = $this->_solr->createSelect($select);
     $resultset = $this->_solr->select($query);
     $data = array();
     $data['numberFound'] = $resultset->getNumFound();
     foreach ($resultset as $doc) {
         $fields = array();
         foreach ($doc as $key => $value) {
             $fields[$key] = $value;
         }
         $data['finds'][] = $fields;
     }
     return $data;
 }
 /**
  * @param integer $start
  * @param integer $count
  * @return array
  */
 public function listPageCounts($start, $count)
 {
     $query = $this->solariumClient->createSelect();
     $query->setQuery("(ns:0)");
     $query->getGrouping()->addField("wid");
     $query->setStart($start);
     $query->setRows($count);
     $query->addSort('wid', Solarium_Query_Select::SORT_ASC);
     $resultSet = $this->solariumClient->select($query);
     $results = [];
     foreach ($resultSet->getGrouping()->getGroups() as $group) {
         /** @var Solarium_Result_Select_Grouping_FieldGroup $group */
         foreach ($group as $groupElement) {
             /** @var Solarium_Result_Select_Grouping_ValueGroup $groupElement */
             $results[] = new WikiPageCountModel($groupElement->getValue(), $groupElement->getNumFound());
         }
     }
     return $results;
 }
 /**
  * @desc Gets a song from Solr index if exists
  *
  * @param LyricsApiSearchParams $searchParams
  *
  * @return null|stdClass
  */
 public function getSong(LyricsApiSearchParams $searchParams)
 {
     $query = $this->client->createSelect();
     $lowerCaseSongName = $searchParams->getLowerCaseField(LyricsApiController::PARAM_SONG);
     $queryText = 'type:%1% AND artist_name_lc:%P2% AND ( song_name_lc:%P3% OR song_name_lc:%P4% )';
     $params = [LyricsUtils::TYPE_SONG, $searchParams->getLowerCaseField(LyricsApiController::PARAM_ARTIST), $lowerCaseSongName, LyricsUtils::removeBrackets($lowerCaseSongName)];
     $query->setQuery($queryText, $params);
     $query->setFields(['artist_name', 'album_id', 'album_name', 'song_name', 'image', 'itunes', self::INDEX_FIELD_NAME_LYRICS]);
     $query->setStart(0)->setRows(1);
     $solrSong = $this->getFirstResult($this->client->select($query));
     if (is_null($solrSong)) {
         return null;
     }
     return $this->getOutputSong($solrSong);
 }
 /** Find objects recorded with proximity to SMRs within a certain distance
  * of a lat lon pair, this is set up to work in kilometres from point. You
  * can adapt this for miles. This perhaps can be swapped out for a SOLR
  * based search in future.
  * @access public
  * @param double $lat
  * @param double $long
  * @param integer $distance
  * @return array
  */
 public function getSMRSNearbyFinds($lat, $lon, $distance)
 {
     $config = $this->_config->solr->asgard->toArray();
     $config['core'] = 'objects';
     $solr = new Solarium_Client(array('adapteroptions' => $config));
     $select = array('query' => '*:*', 'fields' => array('*'), 'filterquery' => array());
     $query = $solr->createSelect($select);
     $helper = $query->getHelper();
     $query->createFilterQuery('geofilt')->setQuery($helper->geofilt($lat, $lon, 'coordinates', $distance));
     $resultset = $solr->select($query);
     $data = array();
     foreach ($resultset as $document) {
         $data[] = array('id' => $document['id'], 'old_findID' => $document['old_findID'], 'county' => $document['county'], 'broadperiod' => $document['broadperiod']);
     }
     return $data;
 }
Example #9
0
 /**
  * Creates a nested query using dismax.
  * @see    WikiaSearchTest::testGetNestedQuery
  * @param  WikiaSearchConfig $searchConfig
  * @return Solarium_Query_Select
  */
 private function getNestedQuery(WikiaSearchConfig $searchConfig)
 {
     wfProfileIn(__METHOD__);
     $nestedQuery = $this->client->createSelect();
     $nestedQuery->setQuery($searchConfig->getQuery());
     $dismax = $nestedQuery->getDismax();
     $boostQueryString = $this->getBoostQueryString($searchConfig);
     $queryFieldsString = $this->getQueryFieldsString($searchConfig);
     $dismax->setQueryFields($queryFieldsString)->setQueryParser('edismax');
     if ($this->wg->SharedExternalDB !== null) {
         $dismax->setPhraseFields($queryFieldsString)->setBoostQuery($this->getBoostQueryString($searchConfig))->setMinimumMatch($searchConfig->getMinimumMatch())->setPhraseSlop(3)->setTie(0.01);
         if (!$searchConfig->getSkipBoostFunctions()) {
             $dismax->setBoostFunctions(implode(' ', $searchConfig->isInterWiki() ? $this->interWikiBoostFunctions : $this->onWikiBoostFunctions));
         }
     }
     wfProfileOut(__METHOD__);
     return $nestedQuery;
 }
 private function getResultMock($responseType)
 {
     $client = new \Solarium_Client();
     $mock = new \Solarium_Result_Select($client, $client->createSelect(), $this->{$responseType}());
     return $mock;
 }
 public function queryPhraseForWikias($query, $hubs, $lang)
 {
     $fields = ["url", "lang_s", "sitename_txt", "id", "score", "description_txt"];
     $config = (new Factory())->getSolariumClientConfig();
     $config['adapteroptions']['core'] = 'xwiki';
     $client = new \Solarium_Client($config);
     $phrase = $this->sanitizeQuery($query);
     $query = $this->prepareXWikiQuery($phrase, $hubs, $lang);
     $select = $client->createSelect();
     $dismax = $select->getDisMax();
     $dismax->setQueryParser('edismax');
     $select->setQuery($query);
     $select->setRows(self::CROSS_WIKI_RESULTS);
     //filter queries
     $select->createFilterQuery('wam')->setQuery('-(wam_i:0)');
     $select->createFilterQuery('users')->setQuery('activeusers_i:[0 TO *]');
     $select->createFilterQuery('pages')->setQuery('articles_i:[50 TO *]');
     //speedydeletion: 547090, scratchpad: 95, lyrics:43339,
     $select->createFilterQuery('banned')->setQuery('-(id:547090) AND -(id:95) AND -(id:43339) AND -(hostname_s:*answers.wikia.com)');
     $dismax->setBoostQuery('domains_txt:"www.' . preg_replace('|\\s*|', '', $phrase) . '.wikia.com"^1000');
     $dismax->setBoostFunctions('wam_i^5 articles_i^0.5');
     $result = $client->select($select);
     return $this->extractData($result, $fields);
 }
 /** Display the index page.
  */
 public function resultsAction()
 {
     $params = array_slice($this->_getAllParams(), 3);
     if (sizeof($params) > 0) {
         $limit = 20;
         $page = $this->_getParam('page');
         if (!isset($page)) {
             $start = 0;
         } else {
             unset($params['page']);
             $start = ($page - 1) * 20;
         }
         $q = '';
         if (array_key_exists('q', $params)) {
             $q .= $params['q'] . ' ';
             unset($params['q']);
         }
         if (array_key_exists('images', $params)) {
             $images = (int) 1;
             unset($params['images']);
         }
         if (array_key_exists('radius', $params)) {
             $d = (int) $params['radius'];
             unset($params['radius']);
         }
         if (array_key_exists('lat', $params)) {
             $lat = (double) $params['lat'];
             unset($params['lat']);
         }
         if (array_key_exists('lon', $params)) {
             $lon = (double) $params['lon'];
             unset($params['lon']);
         }
         $params = array_filter($params);
         foreach ($params as $k => $v) {
             $q .= $k . ':"' . $v . '" ';
         }
         $config = array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beowulf'));
         $select = array('query' => $q, 'start' => $start, 'rows' => $limit, 'fields' => array('*'), 'sort' => array('created' => 'desc'), 'filterquery' => array());
         $allowed = array('fa', 'flos', 'admin', 'treasure');
         if (!in_array($this->getRole(), $allowed)) {
             $select['filterquery']['workflow'] = array('query' => 'workflow:[3 TO *]');
             if (array_key_exists('parish', $params)) {
                 $select['filterquery']['knownas'] = array('query' => 'knownas:["" TO *]');
             }
         }
         if (!is_null($images)) {
             $select['filterquery']['images'] = array('query' => 'thumbnail:[1 TO *]');
         }
         // create a client instance
         $client = new Solarium_Client($config);
         // get a select query instance based on the config
         $query = $client->createSelect($select);
         if (!is_null($d) && !is_null($lon) && !is_null($lat)) {
             $helper = $query->getHelper();
             $query->createFilterQuery('geo')->setQuery($helper->geofilt($lat, $lon, 'coordinates', $d));
         }
         $facetSet = $query->getFacetSet();
         $facetSet->createFacetField('period')->setField('broadperiod');
         $facetSet->createFacetField('county')->setField('county');
         $facetSet->createFacetField('objectType')->setField('objectType');
         $resultset = $client->select($query);
         $pagination = array('page' => $page, 'per_page' => $limit, 'total_results' => $resultset->getNumFound());
         $data = NULL;
         foreach ($resultset as $doc) {
             $fields = array();
             foreach ($doc as $key => $value) {
                 $fields[$key] = $value;
             }
             $data[] = $fields;
         }
         //	Zend_Debug::dump($data);
         //	$periodFacet = $resultset->getFacetSet()->getFacet('period');
         //	foreach($periodFacet as $value => $count) {
         //    echo $value . ' [' . $count . ']<br/>';
         //	}
         //	$objectFacet = $resultset->getFacetSet()->getFacet('objectType');
         //	foreach($objectFacet as $value => $count) {
         //    echo $value . ' [' . $count . ']<br/>';
         //	}
         //	$countyFacet = $resultset->getFacetSet()->getFacet('county');
         //	foreach($countyFacet as $value => $count) {
         //    echo $value . ' [' . $count . ']<br/>';
         //	}
         $paginator = Zend_Paginator::factory($resultset->getNumFound());
         $paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit)->setPageRange(20);
         $this->view->paginator = $paginator;
         $this->view->results = $data;
     } else {
         throw new Pas_Exception_Param('Your search has no parameters!', 500);
     }
 }
<?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(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();
<?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
 public function setUp()
 {
     $this->_plugin = new Solarium_Plugin_PrefetchIterator();
     $this->_client = new Solarium_Client();
     $this->_query = $this->_client->createSelect();
 }
 /** Display all images that a user has added.
  * 
  */
 public function myimagesAction()
 {
     $search = new Pas_Solr_Handler('beowulf');
     $search->setFields(array('id', 'identifier', 'objecttype'));
     $search->setFacets(array('period' => 'broadperiod', 'object' => 'objectType'));
     Zend_Debug::dump($search->execute(array('createdBy' => 56)));
     exit;
     $config = array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beoimages'));
     $select = array('query' => '*:*', 'start' => $this->getStart(), 'rows' => $this->getLimit(), 'fields' => array('*'), 'sort' => array('created' => 'desc'), 'filterquery' => array());
     $client = new Solarium_Client($config);
     // get a select query instance based on the config
     $query = $client->createSelect($select);
     if (!is_null($d) && !is_null($lon) && !is_null($lat)) {
         $helper = $query->getHelper();
         $query->createFilterQuery('geo')->setQuery($helper->geofilt($lat, $lon, 'coordinates', $d));
     }
     $query->createFilterQuery('myimages')->setQuery('createdBy:' . $this->getIdentityForForms());
     $resultset = $client->select($query);
     $this->view->paginator = $this->createPagination($resultset);
     $this->view->results = $this->processResults($resultset);
 }
 function handle($args)
 {
     /*
      * Make sure we have a search term.
      */
     if (!isset($args['term']) || empty($args['term'])) {
         json_error('Search term not provided.');
         die;
     }
     /*
      * Clean up the search term.
      */
     $term = filter_var($args['term'], FILTER_SANITIZE_STRING);
     /*
      * Determine if the search results should display detailed information about each law.
      */
     if (!isset($_GET['detailed']) || empty($_GET['detailed'])) {
         $detailed = FALSE;
     } else {
         $detailed = filter_var($_GET['detailed'], FILTER_SANITIZE_STRING);
         if ($detailed == "true") {
             $detailed = TRUE;
         } elseif ($detailed != "false") {
             $detailed = FALSE;
         } else {
             $detailed = FALSE;
         }
     }
     /*
      * Intialize Solarium.
      */
     $client = new Solarium_Client($GLOBALS['solr_config']);
     /*
      * Set up our query.
      */
     $query = $client->createSelect();
     $query->setQuery($term);
     /*
      * We want the most useful bits extracted as search results snippets.
      */
     $hl = $query->getHighlighting();
     $hl->setFields('catch_line, text');
     /*
      * Specify that we want the first 100 results.
      */
     $query->setStart(0)->setRows(100);
     /*
      * Execute the query.
      */
     $search_results = $client->select($query);
     /*
      * Display uses of the search terms in a preview of the result.
      */
     $highlighted = $search_results->getHighlighting();
     /*
      * If there are no results.
      */
     if (count($search_results) == 0) {
         $response->records = 0;
         $response->total_records = 0;
     }
     /*
      * If we have results.
      */
     /*
      * Instantiate the Law class.
      */
     $law = new Law();
     /*
      * Save an array of the legal code's structure, which we'll use to properly identify the structural
      * data returned by Solr. We hack off the last element of the array, since that identifies the laws
      * themselves, not a structural unit.
      */
     $code_structures = array_slice(explode(',', STRUCTURE), 0, -1);
     $i = 0;
     foreach ($search_results as $document) {
         /*
          * Attempt to display a snippet of the indexed law.
          */
         $snippet = $highlighted->getResult($document->id);
         if ($snippet != FALSE) {
             /*
              * Build the snippet up from the snippet object.
              */
             foreach ($snippet as $field => $highlight) {
                 $response->results->{$i}->excerpt .= strip_tags(implode(' ... ', $highlight)) . ' ... ';
             }
             /*
              * Use an appropriate closing ellipsis.
              */
             if (substr($response->results->{$i}->excerpt, -6) == '. ... ') {
                 $response->results->{$i}->excerpt = substr($response->results->{$i}->excerpt, 0, -6) . '....';
             }
             $response->results->{$i}->excerpt = trim($response->results->{$i}->excerpt);
         }
         /*
          * At the default level of verbosity, just give the data indexed by Solr, plus the URL.
          */
         if ($detailed === FALSE) {
             /*
              * Store the relevant fields within the response we'll send.
              */
             $response->results->{$i}->section_number = $document->section;
             $response->results->{$i}->catch_line = $document->catch_line;
             $response->results->{$i}->text = $document->text;
             $response->results->{$i}->url = $law->get_url($document->section);
             $response->results->{$i}->score = $document->score;
             $response->results->{$i}->ancestry = (object) array_combine($code_structures, explode('/', $document->structure));
         } else {
             $law->section_number = $document->section;
             $response->results->{$i} = $law->get_law();
             $response->results->{$i}->score = $document->score;
         }
         $i++;
     }
     /*
      * Provide the total number of available documents, beyond the number returned by or available
      * via the API.
      */
     $response->total_records = $search_results->getNumFound();
     /*
      * If the request contains a specific list of fields to be returned.
      */
     if (isset($args['fields'])) {
         /*
          * Turn that list into an array.
          */
         $returned_fields = explode(',', urldecode(filter_var($args['fields'], FILTER_SANITIZE_STRING)));
         foreach ($returned_fields as &$field) {
             $field = trim($field);
         }
         /*
          * It's essential to unset $field at the conclusion of the prior loop.
          */
         unset($field);
         /*
          * Step through our response fields and eliminate those that aren't in the requested list.
          */
         foreach ($response as $field => &$value) {
             if (in_array($field, $returned_fields) === false) {
                 unset($response->{$field});
             }
         }
     }
     $this->render($response, 'OK');
 }
Example #18
0
 public function setUp()
 {
     $this->_plugin = new Solarium_Plugin_PostBigRequest();
     $this->_client = new Solarium_Client();
     $this->_query = $this->_client->createSelect();
 }
Example #19
0
 /** Find nearest staff member from solr
  * @access public
  * @return void
  * @todo finish function
  */
 public function findnearestAction()
 {
     $postcode = new Pas_Service_Geo_PostCodeToGeo();
     $geo = $postcode->getData('WC1B 3DG');
     $config = $this->_helper->config()->solr->toArray();
     $config['core'] = 'objects';
     $client = new Solarium_Client(array('adapteroptions' => $config));
     // get a select query instance and a query helper instance
     $select = array('query' => '*:*', 'fields' => array('*'), 'filterquery' => array());
     $query = $client->createSelect($select);
     $helper = $query->getHelper();
     // add a filterquery on a price range, using the helper to generate the range
     $query->createFilterQuery('geodist')->setQuery($helper->geodist($geo['lat'], $geo['lon'], 'coordinates'));
     $resultset = $client->select($query);
     Zend_Debug::dump($resultset);
 }
<?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);
 /** List of the papers available
  */
 public function indexAction()
 {
     $params = array_slice($this->_getAllParams(), 3);
     if (sizeof($params) > 0) {
         $limit = 20;
         $page = $this->_getParam('page');
         if (!isset($page)) {
             $start = 0;
         } else {
             unset($params['page']);
             $start = ($page - 1) * 20;
         }
         $q = '';
         if (array_key_exists('q', $params)) {
             $q .= $params['q'] . ' ';
             unset($params['q']);
         }
         if (array_key_exists('images', $params)) {
             $images = (int) 1;
             unset($params['images']);
         }
         if (array_key_exists('facet', $params)) {
             $facetQuery = $params['facet'];
             unset($params['facet']);
             $this->view->facet = 'facet/' . $facetQuery;
         }
         $params = array_filter($params);
         foreach ($params as $k => $v) {
             $q .= $k . ':"' . $v . '" ';
         }
         $config = array('adapteroptions' => array('host' => '127.0.0.1', 'port' => 8983, 'path' => '/solr/', 'core' => 'beocontent'));
         $select = array('query' => $q, 'start' => $start, 'rows' => $limit, 'fields' => array('*'), 'filterquery' => array());
         $client = new Solarium_Client($config);
         $customizer = $client->getPlugin('customizerequest');
         //	$customizer->createCustomization('transform')
         //           ->setType('param')
         //           ->setName('tr')
         //           ->setValue('example.xsl');
         //	$customizer->createCustomization('format')
         //           ->setType('param')
         //           ->setName('wt')
         //           ->setValue('csv');
         $query = $client->createSelect($select);
         $query->addSort('score', Solarium_Query_Select::SORT_ASC);
         if (isset($facetQuery)) {
             $query->createFilterQuery('sectionType')->setQuery('section:' . $facetQuery);
         }
         $facetSet = $query->getFacetSet();
         $facetSet->createFacetField('section')->setField('section');
         $resultset = $client->select($query);
         //	echo $resultset->getData();
         $this->view->sectionFacet = $resultset->getFacetSet()->getFacet('section');
         $pagination = array('page' => $page, 'per_page' => $limit, 'total_results' => $resultset->getNumFound());
         $data = array();
         foreach ($resultset as $doc) {
             foreach ($doc as $key => $value) {
                 $fields = array();
                 $fields[$key] = $value;
             }
             $data[] = $fields;
         }
         $paginator = Zend_Paginator::factory($resultset->getNumFound());
         $paginator->setCurrentPageNumber($page)->setItemCountPerPage($limit)->setPageRange(20);
         $this->view->paginator = $paginator;
         $this->view->results = $data;
         $this->view->query = $q;
     } else {
         throw new Pas_Exception_Param('Your search has no parameters!', 500);
     }
 }