CacheEngine
class CacheEngine implements EngineInterface (View source)
A TNTSearch engine that keeps each index as PHP arrays in a PSR-16 cache.
It needs no PHP extension and no database, so it works on every server. With the default cache config the indexes are files in the temp folder.
Like the other engines, each method that changes the index saves it before it returns. Saving the whole index for each change is slow, so make many changes between indexBeginTransaction() and indexEndTransaction() to save them once.
Traits
Constants
| CACHE_SERVICE |
The name of the Injector service for the cache that holds the indexes. |
Properties
| public | string | $indexName | ||
| public | array | $config | ||
| public | StemmerInterface | $stemmer | ||
| public | string | $query | ||
| public | bool | $disableOutput | ||
| public | string | $primaryKey | ||
| protected | bool | $excludePrimaryKey | ||
| public | bool | $decodeHTMLEntities | ||
| public | TokenizerInterface | $tokenizer | ||
| public | array | $stopWords | ||
| public | int | $steps | ||
| public | bool | $inMemory | ||
| public | FileReaderInterface|null | $filereader | ||
| public | bool | $asYouType | ||
| public | bool | $fuzziness | ||
| public | int | $fuzzy_prefix_length | ||
| public | int | $fuzzy_max_expansions | ||
| public | int | $fuzzy_distance | ||
| public | bool | $fuzzy_no_limit | ||
| public | int | $maxDocs | ||
| public | PDO|null | $dbh |
Methods
Create an empty index and save it, which replaces any index with the same name.
Start a transaction. Changes are kept in memory until indexEndTransaction() saves them.
Save the changes made since indexBeginTransaction(), and end the transaction.
Discard the changes made since indexBeginTransaction(), and end the transaction.
Get the file for each document ID from an index made by readDocumentsFromFileSystem().
Write each term to a file, most hits first, one term per line.
No description
Details
loadConfig(array $config)
No description
createIndex(string $indexName)
Create an empty index and save it, which replaces any index with the same name.
selectIndex(string $indexName)
No description
void
indexBeginTransaction()
Start a transaction. Changes are kept in memory until indexEndTransaction() saves them.
void
indexEndTransaction()
Save the changes made since indexBeginTransaction(), and end the transaction.
If the changes can't be saved, the transaction stays open so that it can be rolled back.
void
indexRollBackTransaction()
Discard the changes made since indexBeginTransaction(), and end the transaction.
flushIndex(string $indexName)
No description
updateInfoTable(string $key, $value)
No description
getValueFromInfoTable(string $value)
No description
run()
Index the rows from the query, or the files if the "driver" config is "filesystem".
readDocumentsFromFileSystem()
Index the files in the directory from the "location" config.
The "extension" config sets which files to include, and the "exclude" config has paths to leave out.
Collection
filesystemMapIdsToPaths(Collection $docs)
Get the file for each document ID from an index made by readDocumentsFromFileSystem().
Each value is an array with "id" and "path" keys, or null if the document has no file.
buildDictionary($filename, int $count = -1, bool $hits = true, bool $docs = false)
Write each term to a file, most hits first, one term per line.
processDocument(Collection $row)
No description
excludePrimaryKey()
No description
setStopWords(array $stopWords)
No description
insert(array $document)
No description
update(int $id, array $document)
No description
saveToIndex(Collection $stems, int $docId)
No description
saveWordlist(Collection $stems)
Add the terms of one document to the wordlist.
Returns the number of hits in the document keyed by term.
saveDoclist(array $terms, int $docId)
No description
saveHitList(array $stems, int $docId, array $termsList)
No description
delete(int $documentId)
No description
totalDocumentsInCollection()
No description
getWordFromWordList(string $word)
No description
getWordlistByKeyword(string $keyword, bool $isLastWord = false, bool $noLimit = false)
No description
fuzzySearch(string $keyword)
No description
getAllDocumentsForStrictKeyword(array $word, bool $noLimit)
No description
getAllDocumentsForFuzzyKeyword(array $words, bool $noLimit)
No description
getAllDocumentsForWhereKeywordNot(string $keyword, bool $noLimit = false)
No description