/**
  * Retrieves a single document from solr by document id.
  *
  * @param string $documentId
  * @return \ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\SearchResult
  */
 public function getDocumentById($documentId)
 {
     /* @var $query Query */
     $query = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query', $documentId);
     $query->setQueryFieldsFromString('id');
     $response = $this->search->search($query, 0, 1);
     $this->processResponse($documentId, $query, $response);
     $resultDocument = isset($response->response->docs[0]) ? $response->response->docs[0] : null;
     return $resultDocument;
 }
 /**
  * Queries Solr for the current page's documents.
  *
  * @return array An array of Apache_Solr_Document objects
  */
 protected function getIndexDocuments()
 {
     /* @var Query $query */
     $query = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\Query', '');
     $query->setQueryType('standard');
     $query->useRawQueryString(true);
     $query->setQueryString('*:*');
     $query->addFilter('(type:pages AND uid:' . $this->pageId . ') OR (*:* AND pid:' . $this->pageId . ' NOT type:pages)');
     $query->addFilter('siteHash:' . Site::getSiteByPageId($this->pageId)->getSiteHash());
     $query->setFieldList('*');
     $query->setSorting('type asc, title asc');
     $this->search->search($query, 0, 10000);
     return $this->search->getResultDocumentsEscaped();
 }
 /**
  * Performs a search and returns a SearchResultSet.
  *
  * @param SearchRequest $searchRequest
  * @return SearchResultSet
  */
 public function search(SearchRequest $searchRequest)
 {
     /** @var $resultSet SearchResultSet */
     $resultSetClass = $this->getResultSetClassName();
     $resultSet = GeneralUtility::makeInstance($resultSetClass);
     $resultSet->setUsedSearchRequest($searchRequest);
     $this->lastResultSet = $resultSet;
     $resultSet = $this->handleSearchHook('beforeSearch', $resultSet);
     if ($searchRequest->getRawUserQueryIsNull() && !$this->getInitialSearchIsConfigured()) {
         // when no rawQuery was passed or no initialSearch is configured, we pass an empty result set
         return $resultSet;
     }
     if ($searchRequest->getRawUserQueryIsEmptyString() && !$this->typoScriptConfiguration->getSearchQueryAllowEmptyQuery()) {
         // the user entered an empty query string "" or "  " and empty querystring is not allowed
         return $resultSet;
     }
     $rawQuery = $searchRequest->getRawUserQuery();
     $resultsPerPage = $this->getNumberOfResultsPerPage($rawQuery, $searchRequest->getResultsPerPage());
     $query = $this->getPreparedQuery($rawQuery, $resultsPerPage);
     $resultSet->setUsedQuery($query);
     $currentPage = max(0, $searchRequest->getPage());
     // if the number of results per page has been changed by the current request, reset the pagebrowser
     if ($this->resultsPerPageChanged) {
         $currentPage = 0;
     }
     $offSet = $currentPage * $resultsPerPage;
     // performing the actual search, sending the query to the Solr server
     $response = $this->search->search($query, $offSet, null);
     $this->processResponse($rawQuery, $query, $response);
     $resultSet->setResponse($response);
     $resultSet->setUsedPage($currentPage);
     $resultSet->setUsedResultsPerPage($resultsPerPage);
     $resultSet->setUsedAdditionalFilters($this->getAdditionalFilters());
     $resultSet->setUsedSearch($this->search);
     return $this->handleSearchHook('afterSearch', $resultSet);
 }