104 return 'AND page_namespace IN (' .
$namespaces .
')';
115 return $this->db->limitResult( $sql, $this->limit, $this->offset );
127 return ' ORDER BY score(1)';
140 $this->
queryRanking( $filteredTerm, $fulltext ) .
' ' );
149 return $fulltext ?
'si_text' :
'si_title';
160 $match = $this->
parseQuery( $filteredTerm, $fulltext );
161 $page = $this->db->tableName(
'page' );
162 $searchindex = $this->db->tableName(
'searchindex' );
163 return 'SELECT page_id, page_namespace, page_title ' .
164 "FROM $page,$searchindex " .
165 'WHERE page_id=si_page AND ' . $match;
178 $this->searchTerms = [];
180 # @todo FIXME: This doesn't handle parenthetical expressions.
183 if ( preg_match_all(
'/([-+<>~]?)(([' . $lc .
']+)(\*?)|"[^"]*")/',
184 $filteredText, $m, PREG_SET_ORDER ) ) {
185 foreach ( $m
as $terms ) {
188 $temp_terms =
$wgContLang->autoConvertToAllVariants( $terms[2] );
189 if ( is_array( $temp_terms ) ) {
190 $temp_terms = array_unique( array_values( $temp_terms ) );
191 foreach ( $temp_terms
as $t ) {
192 $searchon .= ( $terms[1] ==
'-' ?
' ~' :
' & ' ) . $this->
escapeTerm( $t );
195 $searchon .= ( $terms[1] ==
'-' ?
' ~' :
' & ' ) . $this->
escapeTerm( $terms[2] );
197 if ( !empty( $terms[3] ) ) {
198 $regexp = preg_quote( $terms[3],
'/' );
200 $regexp .=
"[0-9A-Za-z_]+";
203 $regexp = preg_quote( str_replace(
'"',
'', $terms[2] ),
'/' );
205 $this->searchTerms[] = $regexp;
209 $searchon = $this->db->addQuotes( ltrim( $searchon,
' &' ) );
211 return " CONTAINS($field, $searchon, 1) > 0 ";
217 $t = isset( $this->reservedWords[strtoupper(
$t )] ) ?
'{' .
$t .
'}' :
$t;
218 $t = preg_replace(
'/^"(.*)"$/',
'($1)',
$t );
219 $t = preg_replace(
'/([-&|])/',
'\\\\$1',
$t );
233 $dbw->replace(
'searchindex',
239 ],
'SearchOracle::update' );
246 $dbw->query(
"CALL ctx_ddl.sync_index(" .
247 $dbw->addQuotes( $dbw->getDBname() .
'.' . $dbw->tableName(
'si_text_idx',
'raw' ) ) .
")" );
248 $dbw->query(
"CALL ctx_ddl.sync_index(" .
249 $dbw->addQuotes( $dbw->getDBname() .
'.' . $dbw->tableName(
'si_title_idx',
'raw' ) ) .
")" );
262 $dbw->update(
'searchindex',
264 [
'si_page' => $id ],
265 'SearchOracle::updateTitle',
270 $searchChars = parent::legalSearchChars(
$type );
271 if (
$type === self::CHARS_ALL ) {
272 $searchChars =
"\"" . $searchChars;