class fulltext_sphinx

Fulltext search based on the sphinx search daemon

Properties

protected array $stats

Associative array holding index stats

protected array $split_words

Holds the words entered by user, obtained by splitting the entered query on whitespace

protected string $id

Holds unique sphinx id

protected string $indexes

Stores the names of both main and delta sphinx indexes separated by a semicolon

protected SphinxClient $sphinx

Sphinx searchd client object

protected string $phpbb_root_path

Relative path to board root

protected string $php_ext

PHP Extension

protected auth $auth

Auth object

protected config $config

Config object

protected driver_interface $db

Database connection

protected tools_interface $db_tools

Database Tools object

protected string $dbtype

Stores the database type if supported by sphinx

protected dispatcher_interface $phpbb_dispatcher

phpBB event dispatcher object

protected user $user

User object

protected string $config_file_data

Stores the generated content of the sphinx config file

protected string $search_query

Contains tidied search query.

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

bool
config_generate()

Generates content of sphinx.conf

false
split_keywords(string $keywords, string $terms)

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

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.

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

Performs a search on keywords depending on display specific params. You have to run split_keywords() first

bool|int
author_search(string $type, bool $firstpost_only, array $sort_by_sql, string $sort_key, string $sort_dir, string $sort_days, array $ex_fid_ary, string $post_visibility, int $topic_id, array $author_ary, string $author_name, array $id_ary, int $start, int $per_page)

Performs a search on an author's posts without caring about message contents. Depends on display specific params

index(string $mode, int $post_id, string $message, string $subject, int $poster_id, int $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

get_stats()

Collects stats that can be displayed on the index maintenance page

associative
acp()

Returns a list of options for the ACP to display

Details

at line 136
__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
string get_name()

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

Return Value

string Name

at line 185
string get_search_query()

Returns the search_query

Return Value

string

search query

at line 195
false get_word_length()

Returns false as there is no word_len array

Return Value

false

at line 205
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
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/incompatibility encountered, or false if successful

at line 233
protected bool config_generate()

Generates content of sphinx.conf

Return Value

bool

True if sphinx.conf content is correctly generated, false otherwise

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

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

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
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.

  1. 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".
  2. 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

string $type

contains either posts or topics depending on what should be searched for

string $fields

contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)

string $terms

is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words)

array $sort_by_sql

contains SQL code for the ORDER BY part of a query

string $sort_key

is the key of $sort_by_sql for the selected sorting

string $sort_dir

is either a or d representing ASC and DESC

string $sort_days

specifies the maximum amount of days a post may be old

array $ex_fid_ary

specifies an array of forum ids which should not be searched

string $post_visibility

specifies which types of posts the user can view in which forums

int $topic_id

is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched

array $author_ary

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

string $author_name

specifies the author match, when ANONYMOUS is also a search-match

array $id_ary

passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered

int $start

indicates the first index of the page

int $per_page

number of ids each page is supposed to contain

Return Value

bool|int

total number of results

Performs a search on an author's posts without caring about message contents. Depends on display specific params

Parameters

string $type

contains either posts or topics depending on what should be searched for

bool $firstpost_only

if true, only topic starting posts will be considered

array $sort_by_sql

contains SQL code for the ORDER BY part of a query

string $sort_key

is the key of $sort_by_sql for the selected sorting

string $sort_dir

is either a or d representing ASC and DESC

string $sort_days

specifies the maximum amount of days a post may be old

array $ex_fid_ary

specifies an array of forum ids which should not be searched

string $post_visibility

specifies which types of posts the user can view in which forums

int $topic_id

is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched

array $author_ary

an array of author ids

string $author_name

specifies the author match, when ANONYMOUS is also a search-match

array $id_ary

passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered

int $start

indicates the first index of the page

int $per_page

number of ids each page is supposed to contain

Return Value

bool|int

total number of results

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

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

Parameters

string $mode

Contains the post mode: edit, post, reply, quote

int $post_id

The id of the post which is modified/created

string $message

New or updated post content

string $subject

New or updated post subject

int $poster_id

Post author's user id

int $forum_id

The id of the forum in which the post is located

at line 887
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
tidy($create = false)

Nothing needs to be destroyed

Parameters

$create

at line 911
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
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
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
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 994
protected get_stats()

Collects stats that can be displayed on the index maintenance page

at line 1019
associative acp()

Returns a list of options for the ACP to display

Return Value

associative

array containing template and config variables