abstract class base implements search_backend_interface

optional base class for search plugins providing simple caching based on ACM and functions to retrieve ignore_words and synonyms

Constants

SEARCH_RESULT_NOT_IN_CACHE

SEARCH_RESULT_IN_CACHE

SEARCH_RESULT_INCOMPLETE

private BATCH_SIZE

Properties

protected service $cache
protected config $config
protected driver_interface $db
protected user $user

Methods

__construct(service $cache, config $config, driver_interface $db, user $user)

Constructor.

int
obtain_ids(string $search_key, int $result_count, array $id_ary, int $start, int $per_page, string $sort_dir)

Retrieves cached search results

void
save_ids(string $search_key, string $keywords, array $author_ary, int $result_count, array $id_ary, int $start, string $sort_dir)

Caches post/topic ids

void
destroy_cache(array $words, array|bool $authors = false)

Removes old entries from the search results table and removes searches with keywords that contain a word in $words.

array|null
create_index(int $post_counter = 0)

Create fulltext index

array|null
delete_index(int $post_counter = null)

Drop fulltext index

array
forum_ids_with_indexing_enabled()

Return the ids of the forums that have indexing enabled

get_posts_batch_after(int $post_id)

Get batch of posts after id

int
get_max_post_id()

Get post with higher id

string
get_type()

Gets backend class

Details

at line 62
__construct(service $cache, config $config, driver_interface $db, user $user)

Constructor.

Parameters

service $cache
config $config
driver_interface $db
user $user

at line 82
protected int obtain_ids(string $search_key, int $result_count, array $id_ary, int $start, int $per_page, string $sort_dir)

Retrieves cached search results

Parameters

string $search_key

an md5 string generated from all the passed search options to identify the results

int $result_count

will contain the number of all results for the search (not only for the current page)

array $id_ary

is filled with the ids belonging to the requested page that are stored in the cache

int $start

indicates the first index of the page

int $per_page

number of ids each page is supposed to contain

string $sort_dir

is either a or d representing ASC and DESC

Return Value

int

self::SEARCH_RESULT_NOT_IN_CACHE or self::SEARCH_RESULT_IN_CACHE or self::SEARCH_RESULT_INCOMPLETE

at line 161
protected void save_ids(string $search_key, string $keywords, array $author_ary, int $result_count, array $id_ary, int $start, string $sort_dir)

Caches post/topic ids

Parameters

string $search_key

an md5 string generated from all the passed search options to identify the results

string $keywords

contains the keywords as entered by the user

array $author_ary

an array of author ids, if the author should be ignored during the search the array is empty

int $result_count

contains the number of all results for the search (not only for the current page)

array $id_ary

contains a list of post or topic ids that shall be cached, the first element must have the absolute index $start in the result set.

int $start

indicates the first index of the page

string $sort_dir

is either a or d representing ASC and DESC

Return Value

void

at line 271
protected void destroy_cache(array $words, array|bool $authors = false)

Removes old entries from the search results table and removes searches with keywords that contain a word in $words.

Parameters

array $words
array|bool $authors

Return Value

void

at line 324
array|null create_index(int $post_counter = 0)

Create fulltext index

Parameters

int $post_counter

Return Value

array|null

array with current status or null if finished

at line 379
array|null delete_index(int $post_counter = null)

Drop fulltext index

Parameters

int $post_counter

Return Value

array|null

array with current status or null if finished

at line 425
protected array forum_ids_with_indexing_enabled()

Return the ids of the forums that have indexing enabled

Return Value

array

at line 451
protected Generator get_posts_batch_after(int $post_id)

Get batch of posts after id

Parameters

int $post_id

Return Value

Generator

at line 470
protected int get_max_post_id()

Get post with higher id

Return Value

int

at line 484
string get_type()

Gets backend class

Return Value

string