/**
  * Return all the dataobjects that were found in this query
  *
  * @param $evaluatePermissions
  *			Should we evaluate whether the user can view before adding the result to the dataset?
  *
  * @return DataObjectSet
  */
 public function getDataObjects($evaluatePermissions = false, $expandRawObjects = true)
 {
     if (!$this->dataObjects) {
         $this->dataObjects = ArrayList::create();
         $result = $this->getResult();
         $documents = $result && isset($result->response) ? $result->response : null;
         if ($documents && isset($documents->docs)) {
             $totalAdded = 0;
             foreach ($documents->docs as $doc) {
                 $bits = explode('_', $doc->id);
                 if (count($bits) == 3) {
                     list($type, $id, $stage) = $bits;
                 } else {
                     list($type, $id) = $bits;
                     $stage = Versioned::current_stage();
                 }
                 if (!$type || !$id) {
                     singleton('SolrUtils')->log("Invalid solr document ID {$doc->id}", SS_Log::WARN);
                     continue;
                 }
                 if (strpos($doc->id, SolrSearchService::RAW_DATA_KEY) === 0) {
                     $object = $this->inflateRawResult($doc, $expandRawObjects);
                     // $object = new ArrayData($data);
                 } else {
                     if (!class_exists($type)) {
                         continue;
                     }
                     // a double sanity check for the stage here.
                     if ($currentStage = Versioned::current_stage()) {
                         if ($currentStage != $stage) {
                             continue;
                         }
                     }
                     $object = DataObject::get_by_id($type, $id);
                 }
                 if ($object && $object->ID) {
                     // check that the user has permission
                     if (isset($doc->score)) {
                         $object->SearchScore = $doc->score;
                     }
                     $canAdd = true;
                     if ($evaluatePermissions) {
                         // check if we've got a way of evaluating perms
                         if ($object->hasMethod('canView')) {
                             $canAdd = $object->canView();
                         }
                     }
                     if (!$evaluatePermissions || $canAdd) {
                         if ($object->hasMethod('canShowInSearch')) {
                             if ($object->canShowInSearch()) {
                                 $this->dataObjects->push($object);
                             }
                         } else {
                             $this->dataObjects->push($object);
                         }
                     }
                     $totalAdded++;
                 } else {
                     singleton('SolrUtils')->log("Object {$doc->id} is no longer in the system, removing from index", SS_Log::WARN);
                     $this->solr->unindex($type, $id);
                 }
             }
             $this->totalResults = $documents->numFound;
             // update the dos with stats about this query
             $this->dataObjects = PaginatedList::create($this->dataObjects);
             $this->dataObjects->setPageLength($this->queryParameters->limit)->setPageStart($documents->start)->setTotalItems($documents->numFound)->setLimitItems(false);
             //				$paginatedSet->setPaginationFromQuery($set->dataQuery()->query());
             // $this->dataObjects->setPageLimits($documents->start, $this->queryParameters->limit, $documents->numFound);
         }
     }
     return $this->dataObjects;
 }
 public function testIndexObject()
 {
     $search = new SolrSearchService();
     $converted = $search->convertObjectToDocument(array('ID' => 1, 'Title' => 'This document', 'Category' => 'Docs', 'Tags' => array('green', 'food')));
 }
 /**
  * Gets the list of query parsers available
  *
  * @return array
  */
 public function getQueryBuilders()
 {
     return $this->solrSearchService->getQueryBuilders();
 }