‪TYPO3CMS  ‪main
TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository Class Reference

Public Member Functions

 __construct (private readonly Context $context, private readonly ExtensionConfiguration $extensionConfiguration, private readonly TimeTracker $timeTracker, private readonly ConnectionPool $connectionPool,)
 
 initialize (array $settings, array $searchData, array $externalParsers, int|string $searchRootPageIdList)
 
array false doSearch (array $searchWords, int $freeIndexUid)
 
 writeSearchStat (int $pageId, array $searchWords)
 
 getFullTextRowByPhash (string $phash)
 
 getIndexConfigurationById (int $id)
 

Protected Member Functions

 getResultRows_SQLpointer (array $searchWords, int $freeIndexUid)
 
 getResultRows_SQLpointerMysqlFulltext (array $searchWordsArray, int $freeIndexUid)
 
array getSearchString (array $searchWordArray)
 
 execFinalQuery_fulltext (array $searchData, int $freeIndexUid)
 
string getPhashList (array $searchWords)
 
 execPHashListQuery (string $wordSel, string $additionalWhereClause)
 
 searchWord (string $sWord, LikeWildcard $likeWildcard)
 
 searchDistinct (string $sWord)
 
 searchSentence (string $sWord)
 
string sectionTableWhere ()
 
string mediaTypeWhere ()
 
string languageWhere ()
 
string freeIndexUidWhere (int $freeIndexUid)
 
 execFinalQuery (string $list, int $freeIndexUid)
 
bool checkResume (array $row)
 
string getDescendingSortOrderFlag (bool $inverse=false)
 
bool multiplePagesType (string $itemType)
 
int[] getSearchRootPageIdList ()
 

Protected Attributes

array $externalParsers = []
 
string $frontendUserGroupList = ''
 
string $sections = ''
 
SearchType $searchType = SearchType::DISTINCT
 
int $languageUid = 0
 
MediaType $mediaType = MediaType::INTERNAL_PAGES
 
string $sortOrder = ''
 
bool $descendingSortOrderFlag = false
 
int $resultpagePointer = 0
 
int $numberOfResults = 10
 
string $searchRootPageIdList = ''
 
array $wSelClauses = []
 
bool $useExactCount = false
 
bool $displayForbiddenRecords = false
 

Detailed Description

Index search abstraction to search through the index

This class is a specific repository implementation and is not considered part of the Public TYPO3 API.

Definition at line 42 of file IndexSearchRepository.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::__construct ( private readonly Context  $context,
private readonly ExtensionConfiguration  $extensionConfiguration,
private readonly TimeTracker  $timeTracker,
private readonly ConnectionPool  $connectionPool 
)

Definition at line 133 of file IndexSearchRepository.php.

Member Function Documentation

◆ checkResume()

bool TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::checkResume ( array  $row)
protected

Checking if the resume can be shown for the search result (depending on whether the rights are OK) ? Should it also check for gr_list "0,-1"?

Parameters
array$row‪Result row array.
Returns
‪bool Returns TRUE if resume can safely be shown

Definition at line 1020 of file IndexSearchRepository.php.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch().

◆ doSearch()

array false TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::doSearch ( array  $searchWords,
int  $freeIndexUid 
)

Get search result rows / data from database. Returned as data in array.

Parameters
array$searchWords‪Search word array
int$freeIndexUid‪Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
Returns
‪array|false FALSE if no result, otherwise an array with keys for first row, result rows and total number of results found.

Definition at line 176 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\checkResume(), TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointer(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointerMysqlFulltext(), and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\multiplePagesType().

◆ execFinalQuery()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::execFinalQuery ( string  $list,
int  $freeIndexUid 
)
protected

Execute final query, based on phash integer list. The main point is sorting the result in the right order.

Parameters
string$list‪List of phash integers which match the search.
int$freeIndexUid‪Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.

Definition at line 872 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getDescendingSortOrderFlag(), TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointer().

◆ execFinalQuery_fulltext()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::execFinalQuery_fulltext ( array  $searchData,
int  $freeIndexUid 
)
protected

Execute final query, based on phash integer list. The main point is sorting the result in the right order.

mysql fulltext specific helper method

Parameters
array$searchData‪Array with search string, boolean indicator, and fulltext index reference
int$freeIndexUid‪Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.

Definition at line 466 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$searchRootPageIdList, TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\freeIndexUidWhere(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getSearchRootPageIdList(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\languageWhere(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\mediaTypeWhere(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\sectionTableWhere(), and TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointerMysqlFulltext().

◆ execPHashListQuery()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::execPHashListQuery ( string  $wordSel,
string  $additionalWhereClause 
)
protected

Returns a query which selects the search-word from the word/rel tables.

Parameters
string$wordSel‪WHERE clause selecting the word from phash
string$additionalWhereClause‪Additional AND clause in the end of the query.

Definition at line 635 of file IndexSearchRepository.php.

References TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchDistinct(), and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchWord().

◆ freeIndexUidWhere()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::freeIndexUidWhere ( int  $freeIndexUid)
protected

Where-clause for free index-uid value.

Parameters
int$freeIndexUid‪Free Index UID value to limit search to.
Returns
‪string WHERE SQL clause part.

Definition at line 799 of file IndexSearchRepository.php.

References TYPO3\CMS\Webhooks\Message\$uid, TYPO3\CMS\Core\Database\Connection\PARAM_INT, TYPO3\CMS\Core\Utility\GeneralUtility\revExplode(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext().

◆ getDescendingSortOrderFlag()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getDescendingSortOrderFlag ( bool  $inverse = false)
protected

Returns "DESC" or "" depending on the settings of the incoming highest/lowest result order (piVars['desc'])

Parameters
bool$inverse‪If TRUE, inverse the order which is defined by piVars['desc']
Returns
‪string " DESC" or formerly known as tx_indexedsearch_pi->isDescending

Definition at line 1071 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$descendingSortOrderFlag.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery().

◆ getFullTextRowByPhash()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getFullTextRowByPhash ( string  $phash)

Definition at line 297 of file IndexSearchRepository.php.

◆ getIndexConfigurationById()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getIndexConfigurationById ( int  $id)

◆ getPhashList()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getPhashList ( array  $searchWords)
protected

Returns a COMPLETE list of phash-integers matching the search-result composed of the search-words in the $searchWords array. The list of phash integers are unsorted and should be used for subsequent selection of index_phash records for display of the result.

Parameters
array$searchWords‪Search word array
Returns
‪string List of integers

Definition at line 564 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$searchType, TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchDistinct(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchSentence(), TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\searchWord(), and TYPO3\CMS\IndexedSearch\Type\SENTENCE.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointer().

◆ getResultRows_SQLpointer()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getResultRows_SQLpointer ( array  $searchWords,
int  $freeIndexUid 
)
protected

Gets a SQL result pointer to traverse for the search records.

Parameters
array$searchWords‪Search words
int$freeIndexUid‪Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.

Definition at line 337 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery(), and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getPhashList().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch().

◆ getResultRows_SQLpointerMysqlFulltext()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getResultRows_SQLpointerMysqlFulltext ( array  $searchWordsArray,
int  $freeIndexUid 
)
protected

Gets a SQL result pointer to traverse for the search records.

mysql fulltext specific version triggered by ext_conf_template setting 'useMysqlFulltext'

Parameters
array$searchWordsArray‪Search words
int$freeIndexUid‪Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.

Definition at line 361 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext(), and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getSearchString().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch().

◆ getSearchRootPageIdList()

int [] TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getSearchRootPageIdList ( )
protected

A list of integer which should be root-pages to search from

Returns
‪int[]

Definition at line 1098 of file IndexSearchRepository.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\intExplode().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext().

◆ getSearchString()

array TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::getSearchString ( array  $searchWordArray)
protected

Returns a search string for use with MySQL FULLTEXT query

mysql fulltext specific helper method

Parameters
array$searchWordArray‪Search word array
Returns
‪array Search string

Definition at line 393 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$searchType, and TYPO3\CMS\IndexedSearch\Type\SENTENCE.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getResultRows_SQLpointerMysqlFulltext().

◆ initialize()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::initialize ( array  $settings,
array  $searchData,
array  $externalParsers,
int|string  $searchRootPageIdList 
)

initialize all options that are necessary for the search

Parameters
array$settings‪the extbase plugin settings
array$searchData‪the search data

Definition at line 146 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$externalParsers, and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\$searchRootPageIdList.

Referenced by TYPO3\CMS\IndexedSearch\Tests\Functional\IndexSearchRepositoryTest\getSearchRepository().

◆ languageWhere()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::languageWhere ( )
protected

Returns AND statement for selection of language

Returns
‪string AND statement for selection of language

Definition at line 781 of file IndexSearchRepository.php.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext().

◆ mediaTypeWhere()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::mediaTypeWhere ( )
protected

Returns AND statement for selection of media type

Returns
‪string AND statement for selection of media type

Definition at line 765 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Type\ALL_EXTERNAL.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext().

◆ multiplePagesType()

bool TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::multiplePagesType ( string  $itemType)
protected

Returns if an item type is a multipage item type

Parameters
string$itemType‪Item type
Returns
‪bool TRUE if multipage capable

Definition at line 1086 of file IndexSearchRepository.php.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\doSearch().

◆ searchDistinct()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::searchDistinct ( string  $sWord)
protected

Search for one distinct word

Parameters
string$sWord‪the search word

Definition at line 675 of file IndexSearchRepository.php.

References TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execPHashListQuery().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getPhashList().

◆ searchSentence()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::searchSentence ( string  $sWord)
protected

Search for a sentence

Parameters
string$sWord‪the search word

Definition at line 688 of file IndexSearchRepository.php.

References TYPO3\CMS\Core\Database\Query\QueryHelper\stripLogicalOperatorPrefix().

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getPhashList().

◆ searchWord()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::searchWord ( string  $sWord,
LikeWildcard  $likeWildcard 
)
protected

◆ sectionTableWhere()

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::sectionTableWhere ( )
protected

Returns AND statement for selection of section in database. (rootlevel 0-2 + page_id)

Returns
‪string AND clause for selection of section in database.

Definition at line 716 of file IndexSearchRepository.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\intExplode(), and TYPO3\CMS\IndexedSearch\Type\LEVEL_TWO_AND_OUT.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext().

◆ writeSearchStat()

TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::writeSearchStat ( int  $pageId,
array  $searchWords 
)

Write statistics information to database for the search operation if there was at least one search word.

Parameters
array$searchWords‪Search Word array

Definition at line 275 of file IndexSearchRepository.php.

References $GLOBALS, TYPO3\CMS\Core\Database\Connection\PARAM_INT, and TYPO3\CMS\Core\Database\Connection\PARAM_STR.

Member Data Documentation

◆ $descendingSortOrderFlag

bool TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$descendingSortOrderFlag = false
protected

Descending sort order flag formally known as $this->piVars['desc']

Definition at line 88 of file IndexSearchRepository.php.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\getDescendingSortOrderFlag().

◆ $displayForbiddenRecords

bool TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$displayForbiddenRecords = false
protected

Display forbidden records formally known as $this->conf['show.']['forbiddenRecords']

enabled through settings.displayForbiddenRecords

Definition at line 131 of file IndexSearchRepository.php.

◆ $externalParsers

array TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$externalParsers = []
protected

◆ $frontendUserGroupList

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$frontendUserGroupList = ''
protected

Frontend User Group List

Definition at line 52 of file IndexSearchRepository.php.

◆ $languageUid

int TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$languageUid = 0
protected

Language uid formally known as $this->piVars['lang']

Definition at line 70 of file IndexSearchRepository.php.

◆ $mediaType

MediaType TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$mediaType = MediaType::INTERNAL_PAGES
protected

Media type formally known as $this->piVars['media']

Definition at line 76 of file IndexSearchRepository.php.

◆ $numberOfResults

int TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$numberOfResults = 10
protected

Number of results formally known as $this->piVars['result']

Definition at line 100 of file IndexSearchRepository.php.

◆ $resultpagePointer

int TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$resultpagePointer = 0
protected

Result page pointer formally known as $this->piVars['pointer']

Definition at line 94 of file IndexSearchRepository.php.

◆ $searchRootPageIdList

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$searchRootPageIdList = ''
protected

list of all root pages that will be used If this value is set to less than zero (eg. -1) searching will happen in ALL of the page tree with no regard to branches at all.

Definition at line 107 of file IndexSearchRepository.php.

Referenced by TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\execFinalQuery_fulltext(), and TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository\initialize().

◆ $searchType

SearchType TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$searchType = SearchType::DISTINCT
protected

◆ $sections

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$sections = ''
protected

Sections formally known as $this->piVars['sections']

Definition at line 58 of file IndexSearchRepository.php.

◆ $sortOrder

string TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$sortOrder = ''
protected

Sort order formally known as $this->piVars['sort_order']

Definition at line 82 of file IndexSearchRepository.php.

◆ $useExactCount

bool TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$useExactCount = false
protected

Flag for exact search count formally known as $conf['search.']['exactCount']

Continue counting and checking of results even if we are sure they are not displayed in this request. This will slow down your page rendering, but it allows precise search result counters. enabled through settings.exactCount

Definition at line 123 of file IndexSearchRepository.php.

◆ $wSelClauses

array TYPO3\CMS\IndexedSearch\Domain\Repository\IndexSearchRepository::$wSelClauses = []
protected

Select clauses for individual words, will be filled during the search

Definition at line 112 of file IndexSearchRepository.php.