phpBB3


search\fulltext_native
includes/search/fulltext_native.php at line 29

Class fulltext_native

search_backend
└─fulltext_native

public class fulltext_native
extends search_backend

fulltext_native phpBB's own db driven fulltext search, version 2


Field Summary
mixed

$common_words

mixed

$must_contain_ids

mixed

$must_exclude_one_ids

mixed

$must_not_contain_ids

mixed

$search_query

mixed

$stats

mixed

$word_length

Fields inherited from search\search_backend
ignore_words, match_synonym, replace_synonym
Method Summary
void

__construct(mixed error, boolean|string &$error)

Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded.

static void

acp()

Returns a list of options for the ACP to display

boolean|int

author_search(string type, boolean firstpost_only, array sort_by_sql, string sort_key, string sort_dir, string sort_days, array ex_fid_ary, array m_approve_fid_ary, int topic_id, array author_ary, string author_name, mixed id_ary, int start, int per_page, array &$id_ary)

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

string

cleanup(string text, string allowed_chars, string encoding)

Clean up a text to remove non-alphanumeric charactersThis method receives a UTF-8 string, normalizes and validates it, replaces all non-alphanumeric characters with strings then returns the result.

void

delete_index(mixed acp_module, mixed u_action)

Deletes all words from the index

void

get_stats()

void

index(string mode, int post_id, mixed message, mixed subject, int poster_id, int forum_id, string &$message, string &$subject)

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

void

index_created()

Returns true if both FULLTEXT indexes exist

void

index_remove(mixed post_ids, mixed author_ids, mixed forum_ids)

Removes entries from the wordmatch table for the specified post_ids

void

index_stats()

Returns an associative array containing information about the indexes

boolean|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, array m_approve_fid_ary, int topic_id, array author_ary, string author_name, mixed id_ary, int start, int per_page, array &$id_ary)

Performs a search on keywords depending on display specific params.

boolean

split_keywords(string keywords, string terms)

This function fills $this->search_query with the cleaned user search query.

void

tidy()

Tidy up indexes: Tag 'common words' and remove words no longer referenced in the match table

Methods inherited from search\search_backend
__construct, destroy_cache, get_ignore_words, get_synonyms, obtain_ids, save_ids

Field Detail

includes/search/fulltext_native.php at line 34

common_words

public mixed $common_words = array()

includes/search/fulltext_native.php at line 36

must_contain_ids

public mixed $must_contain_ids = array()

includes/search/fulltext_native.php at line 38

must_exclude_one_ids

public mixed $must_exclude_one_ids = array()

includes/search/fulltext_native.php at line 37

must_not_contain_ids

public mixed $must_not_contain_ids = array()

includes/search/fulltext_native.php at line 33

search_query

public mixed $search_query

includes/search/fulltext_native.php at line 31

stats

public mixed $stats = array()

includes/search/fulltext_native.php at line 32

word_length

public mixed $word_length = array()

Method Detail

includes/search/fulltext_native.php at line 47

__construct

public void __construct(mixed error, boolean|string &$error)

Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded.

Parameters:
&$error - is passed by reference and should either be set to false on success or an error message on failure.

includes/search/fulltext_native.php at line 1687

acp

public static void acp()

Returns a list of options for the ACP to display


includes/search/fulltext_native.php at line 819

author_search

public boolean|int author_search(string type, boolean firstpost_only, array sort_by_sql, string sort_key, string sort_dir, string sort_days, array ex_fid_ary, array m_approve_fid_ary, int topic_id, array author_ary, string author_name, mixed id_ary, int start, int per_page, array &$id_ary)

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

Parameters:
type - contains either posts or topics depending on what should be searched for
firstpost_only - if true, only topic starting posts will be considered
sort_by_sql - contains SQL code for the ORDER BY part of a query
sort_key - is the key of $sort_by_sql for the selected sorting
sort_dir - is either a or d representing ASC and DESC
sort_days - specifies the maximum amount of days a post may be old
ex_fid_ary - specifies an array of forum ids which should not be searched
m_approve_fid_ary - specifies an array of forum ids in which the searcher is allowed to view unapproved posts
topic_id - is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
author_ary - an array of author ids
author_name - specifies the author match, when ANONYMOUS is also a search-match
&$id_ary - passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
start - indicates the first index of the page
per_page - number of ids each page is supposed to contain
Returns:
total number of results

includes/search/fulltext_native.php at line 1457

cleanup

public string cleanup(string text, string allowed_chars, string encoding)

Clean up a text to remove non-alphanumeric characters

This method receives a UTF-8 string, normalizes and validates it, replaces all non-alphanumeric characters with strings then returns the result.

Any number of "allowed chars" can be passed as a UTF-8 string in NFC.

Parameters:
text - Text to split, in UTF-8 (not normalized or sanitized)
allowed_chars - String of special chars to allow
encoding - Text encoding
Returns:
Cleaned up text, only alphanumeric chars are left
Todo:
normalizer::cleanup being able to be used?

includes/search/fulltext_native.php at line 1374

delete_index

public void delete_index(mixed acp_module, mixed u_action)

Deletes all words from the index


includes/search/fulltext_native.php at line 1425

get_stats

public void get_stats()

includes/search/fulltext_native.php at line 1093

index

public void index(string mode, int post_id, mixed message, mixed subject, int poster_id, int forum_id, string &$message, string &$subject)

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

Parameters:
mode - Contains the post mode: edit, post, reply, quote
post_id - The id of the post which is modified/created
&$message - New or updated post content
&$subject - New or updated post subject
poster_id - Post author's user id
forum_id - The id of the forum in which the post is located

includes/search/fulltext_native.php at line 1398

index_created

public void index_created()

Returns true if both FULLTEXT indexes exist


includes/search/fulltext_native.php at line 1249

index_remove

public void index_remove(mixed post_ids, mixed author_ids, mixed forum_ids)

Removes entries from the wordmatch table for the specified post_ids


includes/search/fulltext_native.php at line 1411

index_stats

public void index_stats()

Returns an associative array containing information about the indexes


includes/search/fulltext_native.php at line 421

keyword_search

public boolean|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, array m_approve_fid_ary, int topic_id, array author_ary, string author_name, mixed id_ary, int start, int per_page, array &$id_ary)

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

Parameters:
type - contains either posts or topics depending on what should be searched for
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)
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)
sort_by_sql - contains SQL code for the ORDER BY part of a query
sort_key - is the key of $sort_by_sql for the selected sorting
sort_dir - is either a or d representing ASC and DESC
sort_days - specifies the maximum amount of days a post may be old
ex_fid_ary - specifies an array of forum ids which should not be searched
m_approve_fid_ary - specifies an array of forum ids in which the searcher is allowed to view unapproved posts
topic_id - is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
author_ary - an array of author ids if the author should be ignored during the search the array is empty
author_name - specifies the author match, when ANONYMOUS is also a search-match
&$id_ary - passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
start - indicates the first index of the page
per_page - number of ids each page is supposed to contain
Returns:
total number of results

includes/search/fulltext_native.php at line 82

split_keywords

public boolean split_keywords(string keywords, string terms)

This function fills $this->search_query with the cleaned user search query.

If $terms is 'any' then the words will be extracted from the search query and combined with | inside brackets. They will afterwards be treated like an standard search query.

Then it analyses the query and fills the internal arrays $must_not_contain_ids, $must_contain_ids and $must_exclude_one_ids which are later used by keyword_search().

Parameters:
keywords - contains the search query string as entered by the user
terms - is either 'all' (use search query as entered, default words to 'must be contained in post') or 'any' (find all posts containing at least one of the given words)
Returns:
false if no valid keywords were found and otherwise true

includes/search/fulltext_native.php at line 1309

tidy

public void tidy()

Tidy up indexes: Tag 'common words' and remove words no longer referenced in the match table


phpBB3