Manuel:table searchindex
↑ Manuel:Contenu | Schéma de base de données MédiaWiki | table searchindex |
La table searchindex est utilisée pour fournir le searches dans le texte complet. Avant MySQL 5.6, les index du texte complet n'étaient fournis que par le moteur de la table MyISAM, et non pas par InnoDB. La table des textes (actuellement en 1.4 et dans les versions précédentes) utilise néanmoins le type InnoDB pour améliorer la concurrence, et une copie du texte actuel de la page était donc nécessaire pour pouvoir utiliser ces indexes. C'est la raison pour laquelle cette table existe. If using Postgres, this table does not exist: the full text information is stored as columns in the page and pagecontent tables directly.
This table is populated when edits are saved on pages, unless $wgDisableSearchUpdate
is set to true
, or an extension that implements its own search index (like CirrusSearch extension) is installed.
The rebuildtextindex.php maintenance script can be used to populate it from scratch, or updateSearchIndex.php to update it for recently changed pages.
Champs
si_page
Clés vers page_id .
si_title
Munged version of page title.
si_text
Munged version of the current text of the page.
Détails
Les index pour cela sont, si on utilise la Wikipedia anglophone avec sa cardinalité :
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | +-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+ | searchindex | 0 | si_page | 1 | si_page | A | 797275 | NULL | NULL | | BTREE | | | searchindex | 1 | si_title | 1 | si_title | A | 265758 | NULL | NULL | | FULLTEXT | | +-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
Une requête search commune a la forme suivante :
SELECT page_id, page_namespace, page_title FROM `page`,`searchindex`
WHERE page_id=si_page
AND MATCH(si_text) AGAINST('+''searchterm''' IN BOOLEAN MODE)
AND page_is_redirect=0
AND page_namespace IN (0)
LIMIT 20
Dans les versions MediaWiki 1.4 et plus anciennes :
SELECT cur_id,cur_namespace,cur_title,cur_text FROM cur,searchindex
WHERE cur_id=si_page
AND (
MATCH(si_text) AGAINST('+''searchterm''' IN BOOLEAN MODE)
AND cur_is_redirect=0
)
AND cur_namespace IN (0,9,11)
LIMIT 0, 20;
Explain shows the following:
+-------------+--------+-------------------------------------------+---------------+---------+------------+--------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +-------------+--------+-------------------------------------------+---------------+---------+------------+--------+-------------+ | cur | range | cur_id,cur_namespace,name_title_timestamp | cur_namespace | 1 | NULL | 317499 | Using where | | searchindex | eq_ref | si_page | si_page | 4 | cur.cur_id | 1 | Using where | +-------------+--------+-------------------------------------------+---------------+---------+------------+--------+-------------+
Problèmes connus
Le balayage de l'intervalle avec des espaces de noms contenant un grand nombre d'enregistrements nécessite qu'une portion conséquente de la table searchindex soit chargée en RAM. C'est extrêmement coûteux, en particulier à cause du texte entier de l'article que l'on retrouve dans la table searchindex. La suppression du texte dans la table searchindex est une tâche à long terme. Temporary measures may involve adding fields to searchindex and indexing them (and using a self join to allow both that index and the fulltext index to be used) or adding a searchindex index to decrease the number of complete searchindex records which must be read to match the query.
Résumé du schéma
Version de MediaWiki : | ≥ 1.10 |
DESCRIBE searchindex;
+----------+------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+------------------+------+-----+---------+-------+ | si_page | int(10) unsigned | NO | PRI | NULL | | | si_title | varchar(255) | NO | MUL | | | | si_text | mediumtext | NO | MUL | NULL | | +----------+------------------+------+-----+---------+-------+
Versions de MediaWiki : | 1.1 – 1.9 |
DESCRIBE searchindex;
+----------+-----------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-----------------+------+-----+---------+-------+ | si_page | int(8) unsigned | NO | PRI | NULL | | | si_title | varchar(255) | NO | MUL | NULL | | | si_text | mediumtext | NO | MUL | NULL | | +----------+-----------------+------+-----+---------+-------+
Les index
Version de MediaWiki : | ≥ 1.4 |
SHOW INDEX IN searchindex;
+-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | searchindex | 0 | si_page | 1 | si_page | A | 0 | NULL | NULL | | BTREE | | | | searchindex | 1 | si_title | 1 | si_title | NULL | 0 | NULL | NULL | | FULLTEXT | | | | searchindex | 1 | si_text | 1 | si_text | NULL | 0 | NULL | NULL | | FULLTEXT | | | +-------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+