phpBB API Documentation
Class

phpbb\search\fulltext_sphinx

class fulltext_sphinx

Fulltext search based on the sphinx search deamon

Methods

__construct(string|bool $error, string $phpbb_root_path, string $phpEx, auth $auth, config $config, driver_interface $db, user $user, dispatcher_interface $phpbb_dispatcher)

Constructor Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend

string get_name()

Returns the name of this search backend to be displayed to administrators

string get_search_query()

Returns the search_query

false get_word_length()

Returns false as there is no word_len array

array get_common_words()

Returns an empty array as there are no common_words

string|bool init()

Checks permissions and paths, if everything is correct it generates the config file

false split_keywords(string $keywords, string $terms)

Splits keywords entered by a user into an array of words stored in $this->splitwords Stores the tidied search query in $this->searchquery

string sphinx_clean_search_string(string $search_string)

Cleans search query passed into Sphinx search engine, as follows: 1.

keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page)

Performs a search on keywords depending on display specific params.

author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page)

Performs a search on an author's posts without caring about message contents.

index($mode, $post_id, $message, $subject, $poster_id, $forum_id)

Updates wordlist and wordmatch tables when a message is posted or changed

index_remove($post_ids, $author_ids, $forum_ids)

Delete a post from the index after it was deleted

tidy($create = false)

Nothing needs to be destroyed

string|bool create_index($acp_module, $u_action)

Create sphinx table

string|bool delete_index($acp_module, $u_action)

Drop sphinx table

bool index_created($allow_new_files = true)

Returns true if the sphinx table was created

string|bool index_stats()

Returns an associative array containing information about the indexes

associative acp()

Returns a list of options for the ACP to display

Details

at line 136
public __construct(string|bool $error, string $phpbb_root_path, string $phpEx, auth $auth, config $config, driver_interface $db, user $user, dispatcher_interface $phpbb_dispatcher)

Constructor Creates a new \phpbb\search\fulltext_postgres, which is used as a search backend

Parameters

string|bool $error Any error that occurs is passed on through this reference variable otherwise false
string $phpbb_root_path Relative path to phpBB root
string $phpEx PHP file extension
auth $auth Auth object
config $config Config object
driver_interface $db Database object
user $user User object
dispatcher_interface $phpbb_dispatcher Event dispatcher object

at line 175
public string get_name()

Returns the name of this search backend to be displayed to administrators

Return Value

string Name

at line 185
public string get_search_query()

Returns the search_query

Return Value

string search query

at line 195
public false get_word_length()

Returns false as there is no word_len array

Return Value

false

at line 205
public array get_common_words()

Returns an empty array as there are no common_words

Return Value

array common words that are ignored by search backend

at line 215
public string|bool init()

Checks permissions and paths, if everything is correct it generates the config file

Return Value

string|bool Language key of the error/incompatiblity encountered, or false if successful

at line 436
public false split_keywords(string $keywords, string $terms)

Splits keywords entered by a user into an array of words stored in $this->splitwords Stores the tidied search query in $this->searchquery

Parameters

string $keywords Contains the keyword as entered by the user
string $terms is either 'all' or 'any'

Return Value

false if no valid keywords were found and otherwise true

at line 497
public string sphinx_clean_search_string(string $search_string)

Cleans search query passed into Sphinx search engine, as follows: 1.

Hyphenated words are replaced with keyword search for either the exact phrase with spaces or as a single word without spaces eg search for "know-it-all" becomes ("know it all"|"knowitall*") 2. Words with apostrophes are contracted eg "it's" becomes "its" 3. <, >, " and & are decoded from HTML entities. 4. Following special characters used as search operators in Sphinx are preserved when used with correct syntax: (a) quorum matching: "the world is a wonderful place"/3 Finds 3 of the words within the phrase. Number must be between 1 and 9. (b) proximity search: "hello world"~10 Finds hello and world within 10 words of each other. Number can be between 1 and 99. (c) strict word order: aaa << bbb << ccc Finds "aaa" only where it appears before "bbb" and only where "bbb" appears before "ccc". (d) exact match operator: if lemmatizer or stemming enabled, search will find exact match only and ignore other grammatical forms of the same word stem. eg. raining =cats and =dogs will not return "raining cat and dog" eg. ="search this exact phrase" will not return "searched this exact phrase", "searching these exact phrases". 5. Special characters /, ~, << and = not complying with the correct syntax and other reserved operators are escaped and searched literally. Special characters not explicitly listed in charset_table or blend_chars in sphinx.conf will not be indexed and keywords containing them will be ignored by Sphinx. By default, only $, %, & and @ characters are indexed and searchable. String transformation is in backend only and not visible to the end user nor reflected in the results page URL or keyword highlighting.

Parameters

string $search_string

Return Value

string

Performs a search on keywords depending on display specific params.

You have to run split_keywords() first

Parameters

$type
$fields
$terms
$sort_by_sql
$sort_key
$sort_dir
$sort_days
$ex_fid_ary
$post_visibility
$topic_id
$author_ary
$author_name
$id_ary
$start
$per_page

Performs a search on an author's posts without caring about message contents.

Depends on display specific params

Parameters

$type
$firstpost_only
$sort_by_sql
$sort_key
$sort_dir
$sort_days
$ex_fid_ary
$post_visibility
$topic_id
$author_ary
$author_name
$id_ary
$start
$per_page

at line 821
public index($mode, $post_id, $message, $subject, $poster_id, $forum_id)

Updates wordlist and wordmatch tables when a message is posted or changed

Parameters

$mode
$post_id
$message
$subject
$poster_id
$forum_id

at line 887
public index_remove($post_ids, $author_ids, $forum_ids)

Delete a post from the index after it was deleted

Parameters

$post_ids
$author_ids
$forum_ids

at line 901
public tidy($create = false)

Nothing needs to be destroyed

Parameters

$create

at line 911
public string|bool create_index($acp_module, $u_action)

Create sphinx table

Parameters

$acp_module
$u_action

Return Value

string|bool error string is returned incase of errors otherwise false

at line 943
public string|bool delete_index($acp_module, $u_action)

Drop sphinx table

Parameters

$acp_module
$u_action

Return Value

string|bool error string is returned incase of errors otherwise false

at line 960
public bool index_created($allow_new_files = true)

Returns true if the sphinx table was created

Parameters

$allow_new_files

Return Value

bool true if sphinx table was created

at line 977
public string|bool index_stats()

Returns an associative array containing information about the indexes

Return Value

string|bool Language string of error false otherwise

at line 1019
public associative acp()

Returns a list of options for the ACP to display

Return Value

associative array containing template and config variables