first commit

This commit is contained in:
Sven Wappler
2021-04-17 21:20:54 +02:00
parent c93ec9492a
commit cadcc8edb4
406 changed files with 4917 additions and 5157 deletions

View File

@@ -117,7 +117,7 @@ abstract class AbstractFacet
}
/**
* Get solr field name
* Get meilisearch field name
*
* @return string
*/

View File

@@ -118,13 +118,13 @@ abstract class AbstractFacetParser implements FacetParserInterface
/**
* @param array $facetValuesFromSolrResponse
* @param array $facetValuesFromMeilisearchResponse
* @param array $facetValuesFromSearchRequest
* @return mixed
*/
protected function getMergedFacetValueFromSearchRequestAndSolrResponse($facetValuesFromSolrResponse, $facetValuesFromSearchRequest)
protected function getMergedFacetValueFromSearchRequestAndMeilisearchResponse($facetValuesFromMeilisearchResponse, $facetValuesFromSearchRequest)
{
$facetValueItemsToCreate = $facetValuesFromSolrResponse;
$facetValueItemsToCreate = $facetValuesFromMeilisearchResponse;
foreach ($facetValuesFromSearchRequest as $valueFromRequest) {
// if we have options in the request that have not been in the response we add them with a count of 0

View File

@@ -16,7 +16,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\OptionBased\
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacetParser;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\System\Solr\ParsingUtil;
use WapplerSystems\Meilisearch\System\Meilisearch\ParsingUtil;
/**
* Class HierarchyFacetParser
@@ -34,9 +34,9 @@ class HierarchyFacetParser extends AbstractFacetParser
$response = $resultSet->getResponse();
$fieldName = $facetConfiguration['field'];
$label = $this->getPlainLabelOrApplyCObject($facetConfiguration);
$optionsFromSolrResponse = isset($response->facet_counts->facet_fields->{$fieldName}) ? ParsingUtil::getMapArrayFromFlatArray($response->facet_counts->facet_fields->{$fieldName}) : [];
$optionsFromMeilisearchResponse = isset($response->facet_counts->facet_fields->{$fieldName}) ? ParsingUtil::getMapArrayFromFlatArray($response->facet_counts->facet_fields->{$fieldName}) : [];
$optionsFromRequest = $this->getActiveFacetValuesFromRequest($resultSet, $facetName);
$hasOptionsInResponse = !empty($optionsFromSolrResponse);
$hasOptionsInResponse = !empty($optionsFromMeilisearchResponse);
$hasSelectedOptionsInRequest = count($optionsFromRequest) > 0;
$hasNoOptionsToShow = !$hasOptionsInResponse && !$hasSelectedOptionsInRequest;
$hideEmpty = !$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchFacetingShowEmptyFacetsByName($facetName);
@@ -53,7 +53,7 @@ class HierarchyFacetParser extends AbstractFacetParser
$facet->setIsAvailable($hasOptionsInResponse);
$nodesToCreate = $this->getMergedFacetValueFromSearchRequestAndSolrResponse($optionsFromSolrResponse, $optionsFromRequest);
$nodesToCreate = $this->getMergedFacetValueFromSearchRequestAndMeilisearchResponse($optionsFromMeilisearchResponse, $optionsFromRequest);
if ($this->facetOptionsMustBeResorted($facetConfiguration)) {
$nodesToCreate = $this->sortFacetOptionsInNaturalOrder($nodesToCreate);
@@ -96,13 +96,13 @@ class HierarchyFacetParser extends AbstractFacetParser
/**
* Checks if options must be resorted.
*
* Apache Solr facet.sort can be set globally or per facet.
* Meilisearch facet.sort can be set globally or per facet.
* Relevant TypoScript paths:
* plugin.tx_meilisearch.search.faceting.sortBy causes facet.sort Apache Solr parameter
* plugin.tx_meilisearch.search.faceting.sortBy causes facet.sort Meilisearch parameter
* plugin.tx_meilisearch.search.faceting.facets.[facetName].sortBy causes f.<fieldname>.facet.sort parameter
*
* see: https://lucene.apache.org/solr/guide/6_6/faceting.html#Faceting-Thefacet.sortParameter
* see: https://wiki.apache.org/solr/SimpleFacetParameters#facet.sort : "This parameter can be specified on a per field basis."
* see: https://lucene.apache.org/meilisearch/guide/6_6/faceting.html#Faceting-Thefacet.sortParameter
* see: https://wiki.apache.org/meilisearch/SimpleFacetParameters#facet.sort : "This parameter can be specified on a per field basis."
*
* @param array $facetConfiguration
* @return bool

View File

@@ -29,7 +29,7 @@ class HierarchyTool
}
/**
* Replaces @@@slash@@@ with \/ to have the path usable for solr again.
* Replaces @@@slash@@@ with \/ to have the path usable for meilisearch again.
*
* @param string $pathWithReplacedContentSlashes
* @return string

View File

@@ -27,7 +27,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\OptionBased\
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\FacetUrlDecoderInterface;
/**
* Filter encoder to build Solr hierarchy queries from tx_meilisearch[filter]
* Filter encoder to build Meilisearch hierarchy queries from tx_meilisearch[filter]
*
* @author Ingo Renner <ingo@typo3.org>
*/
@@ -42,11 +42,11 @@ class HierarchyUrlDecoder implements FacetUrlDecoderInterface
const DELIMITER = '/';
/**
* Parses the given hierarchy filter and returns a Solr filter query.
* Parses the given hierarchy filter and returns a Meilisearch filter query.
*
* @param string $hierarchy The hierarchy filter query.
* @param array $configuration Facet configuration
* @return string Lucene query language filter to be used for querying Solr
* @return string Lucene query language filter to be used for querying Meilisearch
*/
public function decode($hierarchy, array $configuration = [])
{

View File

@@ -16,7 +16,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\OptionBased\
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacetParser;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\System\Solr\ResponseAdapter;
use WapplerSystems\Meilisearch\System\Meilisearch\ResponseAdapter;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
@@ -49,10 +49,10 @@ class OptionsFacetParser extends AbstractFacetParser
$response = $resultSet->getResponse();
$fieldName = $facetConfiguration['field'];
$label = $this->getPlainLabelOrApplyCObject($facetConfiguration);
$optionsFromSolrResponse = $this->getOptionsFromSolrResponse($facetName, $response);
$metricsFromSolrResponse = $this->getMetricsFromSolrResponse($facetName, $response);
$optionsFromMeilisearchResponse = $this->getOptionsFromMeilisearchResponse($facetName, $response);
$metricsFromMeilisearchResponse = $this->getMetricsFromMeilisearchResponse($facetName, $response);
$optionsFromRequest = $this->getActiveFacetValuesFromRequest($resultSet, $facetName);
$hasOptionsInResponse = !empty($optionsFromSolrResponse);
$hasOptionsInResponse = !empty($optionsFromMeilisearchResponse);
$hasSelectedOptionsInRequest = count($optionsFromRequest) > 0;
$hasNoOptionsToShow = !$hasOptionsInResponse && !$hasSelectedOptionsInRequest;
$hideEmpty = !$resultSet->getUsedSearchRequest()->getContextTypoScriptConfiguration()->getSearchFacetingShowEmptyFacetsByName($facetName);
@@ -75,7 +75,7 @@ class OptionsFacetParser extends AbstractFacetParser
$facet->setIsUsed($hasActiveOptions);
$facet->setIsAvailable($hasOptionsInResponse);
$optionsToCreate = $this->getMergedFacetValueFromSearchRequestAndSolrResponse($optionsFromSolrResponse, $optionsFromRequest);
$optionsToCreate = $this->getMergedFacetValueFromSearchRequestAndMeilisearchResponse($optionsFromMeilisearchResponse, $optionsFromRequest);
foreach ($optionsToCreate as $optionsValue => $count) {
if ($this->getIsExcludedFacetValue($optionsValue, $facetConfiguration)) {
continue;
@@ -83,11 +83,11 @@ class OptionsFacetParser extends AbstractFacetParser
$isOptionsActive = in_array($optionsValue, $optionsFromRequest);
$label = $this->getLabelFromRenderingInstructions($optionsValue, $count, $facetName, $facetConfiguration);
$facet->addOption($this->objectManager->get(Option::class, $facet, $label, $optionsValue, $count, $isOptionsActive, $metricsFromSolrResponse[$optionsValue]));
$facet->addOption($this->objectManager->get(Option::class, $facet, $label, $optionsValue, $count, $isOptionsActive, $metricsFromMeilisearchResponse[$optionsValue]));
}
// after all options have been created we apply a manualSortOrder if configured
// the sortBy (lex,..) is done by the solr server and triggered by the query, therefore it does not
// the sortBy (lex,..) is done by the meilisearch server and triggered by the query, therefore it does not
// need to be handled in the frontend.
$this->applyManualSortOrder($facet, $facetConfiguration);
$this->applyReverseOrder($facet, $facetConfiguration);
@@ -104,20 +104,20 @@ class OptionsFacetParser extends AbstractFacetParser
* @param ResponseAdapter $response
* @return array
*/
protected function getOptionsFromSolrResponse($facetName, ResponseAdapter $response)
protected function getOptionsFromMeilisearchResponse($facetName, ResponseAdapter $response)
{
$optionsFromSolrResponse = [];
$optionsFromMeilisearchResponse = [];
if (!isset($response->facets->{$facetName})) {
return $optionsFromSolrResponse;
return $optionsFromMeilisearchResponse;
}
foreach ($response->facets->{$facetName}->buckets as $bucket) {
$optionValue = $bucket->val;
$optionCount = $bucket->count;
$optionsFromSolrResponse[$optionValue] = $optionCount;
$optionsFromMeilisearchResponse[$optionValue] = $optionCount;
}
return $optionsFromSolrResponse;
return $optionsFromMeilisearchResponse;
}
/**
@@ -125,9 +125,9 @@ class OptionsFacetParser extends AbstractFacetParser
* @param ResponseAdapter $response
* @return array
*/
protected function getMetricsFromSolrResponse($facetName, ResponseAdapter $response)
protected function getMetricsFromMeilisearchResponse($facetName, ResponseAdapter $response)
{
$metricsFromSolrResponse = [];
$metricsFromMeilisearchResponse = [];
if (!isset($response->facets->{$facetName}->buckets)) {
return [];
@@ -138,11 +138,11 @@ class OptionsFacetParser extends AbstractFacetParser
foreach ($bucketVariables as $key => $value) {
if (strpos($key, 'metrics_') === 0) {
$metricsKey = str_replace('metrics_', '', $key);
$metricsFromSolrResponse[$bucket->val][$metricsKey] = $value;
$metricsFromMeilisearchResponse[$bucket->val][$metricsKey] = $value;
}
}
}
return $metricsFromSolrResponse;
return $metricsFromMeilisearchResponse;
}
}

View File

@@ -16,7 +16,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\OptionBased\
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacetParser;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\System\Solr\ResponseAdapter;
use WapplerSystems\Meilisearch\System\Meilisearch\ResponseAdapter;
/**
* Class QueryGroupFacetParser
@@ -86,7 +86,7 @@ class QueryGroupFacetParser extends AbstractFacetParser
// after all options have been created we apply a manualSortOrder if configured
// the sortBy (lex,..) is done by the solr server and triggered by the query, therefore it does not
// the sortBy (lex,..) is done by the meilisearch server and triggered by the query, therefore it does not
// need to be handled in the frontend.
$this->applyManualSortOrder($facet, $facetConfiguration);
$this->applyReverseOrder($facet, $facetConfiguration);
@@ -112,7 +112,7 @@ class QueryGroupFacetParser extends AbstractFacetParser
// todo: add test cases to check if this is needed https://forge.typo3.org/issues/45440
// remove tags from the facet.query response, for facet.field
// and facet.range Solr does that on its own automatically
// and facet.range Meilisearch does that on its own automatically
$rawValue = preg_replace('/^\{!ex=[^\}]*\}(.*)/', '\\1', $rawValue);
list($field, $query) = explode(':', $rawValue, 2);

View File

@@ -16,7 +16,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\RangeBased;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\AbstractFacetParser;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\SearchResultSet;
use WapplerSystems\Meilisearch\System\Solr\ParsingUtil;
use WapplerSystems\Meilisearch\System\Meilisearch\ParsingUtil;
/**
* Class AbstractRangeFacetParser

View File

@@ -103,7 +103,7 @@ class DateRange extends AbstractRangeFacetItem
}
/**
* Retrieves the end date that was received from solr for this facet.
* Retrieves the end date that was received from meilisearch for this facet.
*
* @return \DateTime
*/
@@ -113,7 +113,7 @@ class DateRange extends AbstractRangeFacetItem
}
/**
* Retrieves the start date that was received from solr for this facet.
* Retrieves the start date that was received from meilisearch for this facet.
*
* @return \DateTime
*/

View File

@@ -30,7 +30,7 @@ use WapplerSystems\Meilisearch\System\DateTime\FormatService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Parser to build solr range queries from tx_meilisearch[filter]
* Parser to build meilisearch range queries from tx_meilisearch[filter]
*
* @author Markus Goldbach <markus.goldbach@dkd.de>
*/
@@ -45,12 +45,12 @@ class DateRangeUrlDecoder implements FacetUrlDecoderInterface
const DELIMITER = '-';
/**
* Parses the given date range from a GET parameter and returns a Solr
* Parses the given date range from a GET parameter and returns a Meilisearch
* date range filter.
*
* @param string $dateRange The range filter query string from the query URL
* @param array $configuration Facet configuration
* @return string Lucene query language filter to be used for querying Solr
* @return string Lucene query language filter to be used for querying Meilisearch
*/
public function decode($dateRange, array $configuration = [])
{

View File

@@ -102,7 +102,7 @@ class NumericRange extends AbstractRangeFacetItem
}
/**
* Retrieves the end date that was received from solr for this facet.
* Retrieves the end date that was received from meilisearch for this facet.
*
* @return float
*/
@@ -112,7 +112,7 @@ class NumericRange extends AbstractRangeFacetItem
}
/**
* Retrieves the start date that was received from solr for this facet.
* Retrieves the start date that was received from meilisearch for this facet.
*
* @return float
*/

View File

@@ -29,7 +29,7 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\RangeBased\N
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Facets\FacetUrlDecoderInterface;
/**
* Parser to build Solr range queries from tx_meilisearch[filter]
* Parser to build Meilisearch range queries from tx_meilisearch[filter]
*
* @author Markus Goldbach <markus.goldbach@dkd.de>
* @author Ingo Renner <ingo@typo3.org>
@@ -46,12 +46,12 @@ class NumericRangeUrlDecoder implements FacetUrlDecoderInterface
const DELIMITER = '-';
/**
* Parses the given range from a GET parameter and returns a Solr range
* Parses the given range from a GET parameter and returns a Meilisearch range
* filter.
*
* @param string $range The range filter from the URL.
* @param array $configuration Facet configuration
* @return string Lucene query language filter to be used for querying Solr
* @return string Lucene query language filter to be used for querying Meilisearch
* @throws \InvalidArgumentException
*/
public function decode($range, array $configuration = [])

View File

@@ -32,7 +32,7 @@ use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* A ResultParser is responsible to create the result object structure from the \Apache_Solr_Response
* A ResultParser is responsible to create the result object structure from the \Apache_Meilisearch_Response
* and assign it to the SearchResultSet.
*/
abstract class AbstractResultParser {

View File

@@ -62,7 +62,7 @@ class DefaultResultParser extends AbstractResultParser {
}
foreach ($documents as $searchResult) {
$searchResultObject = $this->searchResultBuilder->fromApacheSolrDocument($searchResult);
$searchResultObject = $this->searchResultBuilder->fromApacheMeilisearchDocument($searchResult);
$searchResults[] = $searchResultObject;
}

View File

@@ -26,11 +26,11 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result\Parser;
***************************************************************/
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
use WapplerSystems\Meilisearch\Util;
/**
* Applies htmlspecialschars on documents of a solr response.
* Applies htmlspecialschars on documents of a meilisearch response.
*/
class DocumentEscapeService {
@@ -44,7 +44,7 @@ class DocumentEscapeService {
* @param TypoScriptConfiguration|null $typoScriptConfiguration
*/
public function __construct(TypoScriptConfiguration $typoScriptConfiguration = null) {
$this->typoScriptConfiguration = $typoScriptConfiguration ?? Util::getSolrConfiguration();
$this->typoScriptConfiguration = $typoScriptConfiguration ?? Util::getMeilisearchConfiguration();
}
/**
@@ -56,13 +56,13 @@ class DocumentEscapeService {
*/
public function applyHtmlSpecialCharsOnAllFields(array $documents)
{
$trustedSolrFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();
$trustedMeilisearchFields = $this->typoScriptConfiguration->getSearchTrustedFieldsArray();
foreach ($documents as $key => $document) {
$fieldNames = array_keys($document->getFields() ?? []);
foreach ($fieldNames as $fieldName) {
if (is_array($trustedSolrFields) && in_array($fieldName, $trustedSolrFields)) {
if (is_array($trustedMeilisearchFields) && in_array($fieldName, $trustedMeilisearchFields)) {
// we skip this field, since it was marked as secure
continue;
}

View File

@@ -26,10 +26,10 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result;
***************************************************************/
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping\GroupItem;
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
/**
* Solr document class that should be used in the frontend in the search context.
* Meilisearch document class that should be used in the frontend in the search context.
*
* @author Timo Schmidt <timo.schmidt@dkd.de>
*/
@@ -38,7 +38,7 @@ class SearchResult extends Document
/**
* The variant field value
*
* Value of Solr collapse field, which is defined via
* Value of Meilisearch collapse field, which is defined via
* TypoScript variable "variants.variantField"
*
* @var string

View File

@@ -25,24 +25,24 @@ namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result;
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* The SearchResultBuilder is responsible to build a SearchResult object from an \WapplerSystems\Meilisearch\System\Solr\Document\Document
* The SearchResultBuilder is responsible to build a SearchResult object from an \WapplerSystems\Meilisearch\System\Meilisearch\Document\Document
* and should use a different class as SearchResult if configured.
*/
class SearchResultBuilder {
/**
* This method is used to wrap the original solr document instance in an instance of the configured SearchResult
* This method is used to wrap the original meilisearch document instance in an instance of the configured SearchResult
* class.
*
* @param Document $originalDocument
* @throws \InvalidArgumentException
* @return SearchResult
*/
public function fromApacheSolrDocument(Document $originalDocument)
public function fromApacheMeilisearchDocument(Document $originalDocument)
{
$searchResultClassName = $this->getResultClassName();
@@ -60,7 +60,7 @@ class SearchResultBuilder {
*/
protected function getResultClassName()
{
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName ']) ?
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultClassName '] : SearchResult::class;
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultClassName ']) ?
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultClassName '] : SearchResult::class;
}
}

View File

@@ -25,7 +25,7 @@ use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* This processor is used to transform the solr response into a
* This processor is used to transform the meilisearch response into a
* domain object hierarchy that can be used in the application (controller and view).
*
* @author Frans Saris <frans@beech.it>
@@ -83,7 +83,7 @@ class ResultSetReconstitutionProcessor implements SearchResultSetProcessor
$resultSet = $this->parseSpellCheckingResponseIntoObjects($resultSet);
$resultSet = $this->parseSortingIntoObjects($resultSet);
// here we can reconstitute other domain objects from the solr response
// here we can reconstitute other domain objects from the meilisearch response
$resultSet = $this->parseFacetsIntoObjects($resultSet);
return $resultSet;

View File

@@ -35,10 +35,10 @@ use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Sorting\SortingCollection
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Spellchecking\Suggestion;
use WapplerSystems\Meilisearch\Domain\Search\SearchRequest;
use WapplerSystems\Meilisearch\Search;
use WapplerSystems\Meilisearch\System\Solr\ResponseAdapter;
use WapplerSystems\Meilisearch\System\Meilisearch\ResponseAdapter;
/**
* The SearchResultSet is used to provided access to the \Apache_Solr_Response and
* The SearchResultSet is used to provided access to the \Apache_Meilisearch_Response and
* other relevant information, like the used Query and Request objects.
*
* @author Timo Schmidt <timo.schmidt@dkd.de>

View File

@@ -41,10 +41,10 @@ use WapplerSystems\Meilisearch\Search\QueryAware;
use WapplerSystems\Meilisearch\Search\SearchAware;
use WapplerSystems\Meilisearch\Search\SearchComponentManager;
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
use WapplerSystems\Meilisearch\System\Solr\ResponseAdapter;
use WapplerSystems\Meilisearch\System\Solr\SolrIncompleteResponseException;
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
use WapplerSystems\Meilisearch\System\Meilisearch\ResponseAdapter;
use WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchIncompleteResponseException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result\SearchResultBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -79,7 +79,7 @@ class SearchResultSetService
/**
* @var boolean
*/
protected $isSolrAvailable = false;
protected $isMeilisearchAvailable = false;
/**
* @var TypoScriptConfiguration
@@ -87,7 +87,7 @@ class SearchResultSetService
protected $typoScriptConfiguration;
/**
* @var SolrLogManager
* @var MeilisearchLogManager
*/
protected $logger = null;
@@ -109,17 +109,17 @@ class SearchResultSetService
/**
* @param TypoScriptConfiguration $configuration
* @param Search $search
* @param SolrLogManager $solrLogManager
* @param MeilisearchLogManager $meilisearchLogManager
* @param SearchResultBuilder $resultBuilder
* @param QueryBuilder $queryBuilder
*/
public function __construct(TypoScriptConfiguration $configuration, Search $search, SolrLogManager $solrLogManager = null, SearchResultBuilder $resultBuilder = null, QueryBuilder $queryBuilder = null)
public function __construct(TypoScriptConfiguration $configuration, Search $search, MeilisearchLogManager $meilisearchLogManager = null, SearchResultBuilder $resultBuilder = null, QueryBuilder $queryBuilder = null)
{
$this->search = $search;
$this->typoScriptConfiguration = $configuration;
$this->logger = $solrLogManager ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
$this->logger = $meilisearchLogManager ?? GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
$this->searchResultBuilder = $resultBuilder ?? GeneralUtility::makeInstance(SearchResultBuilder::class);
$this->queryBuilder = $queryBuilder ?? GeneralUtility::makeInstance(QueryBuilder::class, /** @scrutinizer ignore-type */ $configuration, /** @scrutinizer ignore-type */ $solrLogManager);
$this->queryBuilder = $queryBuilder ?? GeneralUtility::makeInstance(QueryBuilder::class, /** @scrutinizer ignore-type */ $configuration, /** @scrutinizer ignore-type */ $meilisearchLogManager);
}
/**
@@ -134,10 +134,10 @@ class SearchResultSetService
* @param bool $useCache
* @return bool
*/
public function getIsSolrAvailable($useCache = true)
public function getIsMeilisearchAvailable($useCache = true)
{
$this->isSolrAvailable = $this->search->ping($useCache);
return $this->isSolrAvailable;
$this->isMeilisearchAvailable = $this->search->ping($useCache);
return $this->isMeilisearchAvailable;
}
/**
@@ -179,8 +179,8 @@ class SearchResultSetService
*/
protected function getResultSetClassName()
{
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultSetClassName ']) ?
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['searchResultSetClassName '] : SearchResultSet::class;
return isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultSetClassName ']) ?
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['searchResultSetClassName '] : SearchResultSet::class;
}
/**
@@ -204,7 +204,7 @@ class SearchResultSetService
$this->initializeRegisteredSearchComponents($query, $searchRequest);
$resultSet->setUsedQuery($query);
// performing the actual search, sending the query to the Solr server
// performing the actual search, sending the query to the Meilisearch server
$query = $this->modifyQuery($query, $searchRequest, $this->search);
$response = $this->doASearch($query, $searchRequest);
@@ -294,7 +294,7 @@ class SearchResultSetService
}
/**
* Executes the search and builds a fake response for a current bug in Apache Solr 6.3
* Executes the search and builds a fake response for a current bug in Meilisearch 6.3
*
* @param Query $query
* @param SearchRequest $searchRequest
@@ -308,7 +308,7 @@ class SearchResultSetService
$response = $this->search->search($query, $offSet, null);
if($response === null) {
throw new SolrIncompleteResponseException('The response retrieved from solr was incomplete', 1505989678);
throw new MeilisearchIncompleteResponseException('The response retrieved from meilisearch was incomplete', 1505989678);
}
return $response;
@@ -375,19 +375,19 @@ class SearchResultSetService
}
/**
* Allows to modify a query before eventually handing it over to Solr.
* Allows to modify a query before eventually handing it over to Meilisearch.
*
* @param Query $query The current query before it's being handed over to Solr.
* @param Query $query The current query before it's being handed over to Meilisearch.
* @param SearchRequest $searchRequest The searchRequest, relevant in the current context
* @param Search $search The search, relevant in the current context
* @throws \UnexpectedValueException
* @return Query The modified query that is actually going to be given to Solr.
* @return Query The modified query that is actually going to be given to Meilisearch.
*/
protected function modifyQuery(Query $query, SearchRequest $searchRequest, Search $search)
{
// hook to modify the search query
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchQuery'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['modifySearchQuery'] as $classReference) {
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['modifySearchQuery'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['modifySearchQuery'] as $classReference) {
$queryModifier = $this->objectManager->get($classReference);
if ($queryModifier instanceof Modifier) {
@@ -413,7 +413,7 @@ class SearchResultSetService
}
/**
* Retrieves a single document from solr by document id.
* Retrieves a single document from meilisearch by document id.
*
* @param string $documentId
* @return SearchResult
@@ -431,7 +431,7 @@ class SearchResultSetService
throw new \UnexpectedValueException("Response did not contain a valid Document object");
}
return $this->searchResultBuilder->fromApacheSolrDocument($resultDocument);
return $this->searchResultBuilder->fromApacheMeilisearchDocument($resultDocument);
}
/**
@@ -443,11 +443,11 @@ class SearchResultSetService
*/
private function handleSearchHook($eventName, SearchResultSet $resultSet)
{
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$eventName])) {
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch'][$eventName])) {
return $resultSet;
}
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr'][$eventName] as $classReference) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch'][$eventName] as $classReference) {
$afterSearchProcessor = $this->objectManager->get($classReference);
if ($afterSearchProcessor instanceof SearchResultSetProcessor) {
$afterSearchProcessor->process($resultSet);