MaxSem has submitted this change and it was merged.
Change subject: Remove support for safeifier
......................................................................
Remove support for safeifier
Changes in elasticsearch are making this part of our es plugins harder
to maintain. We're not using it in production so drop the feature rather
than continuing to pay the maintenance cost.
Bug: T133709
Depends-On: I6409696e4352828e24fe310f7872d8161b8868a8
Change-Id: I47ac272c4d7cf2cd1e9ea15946fc87834f5b1358
---
M CirrusSearch.php
M README
M includes/Search/Filters.php
M includes/Search/SearchContext.php
M includes/Search/SearchTextQueryBuilders.php
M tests/jenkins/FullyFeaturedConfig.php
6 files changed, 14 insertions(+), 56 deletions(-)
Approvals:
MaxSem: Looks good to me, approved
DCausse: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/CirrusSearch.php b/CirrusSearch.php
index cba4dbd..778edce 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -132,7 +132,7 @@
// Should CirrusSearch try to use the wikimedia/extra plugin? An empty array
// means don't use it at all.
-$wgCirrusSearchWikimediaExtraPlugin = array();
+//
// Here is an example to enable faster regex matching:
// $wgCirrusSearchWikimediaExtraPlugin[ 'regex' ] =
// array( 'build', 'use', 'max_inspect' => 10000 );
@@ -143,18 +143,15 @@
// the 'max_inspect' key is the maximum number of pages to recheck the regex
// against. Its optional and defaults to 10000 which seems like a reasonable
// compromise to keep regexes fast while still producing good results.
-// This example enables the safer query's phrase processing:
-// $wgCirrusSearchWikimediaExtraPlugin[ 'safer' ] = array(
-// 'phrase' => array(
-// 'max_terms_in_all_queries' => 128,
-// )
-// );
+//
// This turns on noop-detection for updates and is compatible with
-// wikimedia-extra versions 1.3.1, 1.4.2, and 1.5.0:
+// wikimedia-extra versions 1.3.1, 1.4.2, 1.5.0, and greater:
// $wgCirrusSearchWikimediaExtraPlugin[ 'super_detect_noop' ] = true;
+//
// This allows forking on reindexing and is compatible with wikimedia-extra
-// versions 1.3.1, 1.4.2, and 1.5.0
+// versions 1.3.1, 1.4.2, 1.5.0, and greater:
// $wgCirrusSearchWikimediaExtraPlugin[ 'id_hash_mod_filter' ] = true;
+$wgCirrusSearchWikimediaExtraPlugin = array();
// Should CirrusSearch try to support regular expressions with insource:?
// These can be really expensive, but mostly ok, especially if you have the
diff --git a/README b/README
index e4e3862..322c75a 100644
--- a/README
+++ b/README
@@ -358,7 +358,7 @@
- version => '1.6.0',
+ version => '1.7.0',
}
- ## Trigram accelerated regular expressions, "safer" query, and friends
+ ## Trigram accelerated regular expressions, and friends
elasticsearch::plugin { 'extra':
group => 'org.wikimedia.search',
name => 'extra',
diff --git a/includes/Search/Filters.php b/includes/Search/Filters.php
index 58ff5a5..bde8d7a 100644
--- a/includes/Search/Filters.php
+++ b/includes/Search/Filters.php
@@ -163,15 +163,14 @@
$query->setAllowLeadingWildcard(
$escaper->getAllowLeadingWildcard() );
$query->setFuzzyPrefixLength( 2 );
$query->setRewrite( 'top_terms_boost_1024' );
- $wrappedQuery = $context->wrapInSaferIfPossible( $query, false
);
$updateReferences =
function ( &$fuzzyQueryRef, &$filterDestinationRef,
&$highlightSourceRef, &$searchContainedSyntaxRef )
- use ( $fuzzyQuery, $wrappedQuery,
$updateHighlightSourceRef ) {
+ use ( $fuzzyQuery, $query,
$updateHighlightSourceRef ) {
$fuzzyQueryRef = $fuzzyQuery;
- $filterDestinationRef[] = $wrappedQuery;
+ $filterDestinationRef[] = $query;
if ($updateHighlightSourceRef) {
- $highlightSourceRef[] = array(
'query' => $wrappedQuery );
+ $highlightSourceRef[] = array(
'query' => $query );
}
$searchContainedSyntaxRef = true;
};
diff --git a/includes/Search/SearchContext.php
b/includes/Search/SearchContext.php
index bfb2431..122c7a9 100644
--- a/includes/Search/SearchContext.php
+++ b/includes/Search/SearchContext.php
@@ -131,31 +131,6 @@
}
/**
- * @return bool true if we can use the safer query from the wikimedia
extra
- * plugin
- */
- public function isUseSafer() {
- return !is_null( $this->config->getElement(
'CirrusSearchWikimediaExtraPlugin', 'safer' ) );
- }
-
- /**
- * @param AbstractQuery $query
- * @param boolean $isRescore
- * @return \Elastica\Query\Simple
- */
- public function wrapInSaferIfPossible( AbstractQuery $query, $isRescore
) {
- // @todo: move this code to a common base class when Filters is
refactored as non-static
- $saferQuery = $this->config->getElement(
'CirrusSearchWikimediaExtraPlugin', 'safer' );
- if ( is_null( $saferQuery ) ) {
- return $query;
- }
- $saferQuery[ 'query' ] = $query->toArray();
- $tooLargeAction = $isRescore ? 'convert_to_match_all_query' :
'convert_to_term_queries';
- $saferQuery[ 'phrase' ][ 'phrase_too_large_action' ] =
$tooLargeAction;
- return new \Elastica\Query\Simple( array( 'safer' =>
$saferQuery ) );
- }
-
- /**
* @return true if the query contains special syntax
*/
public function isSearchContainedSyntax() {
diff --git a/includes/Search/SearchTextQueryBuilders.php
b/includes/Search/SearchTextQueryBuilders.php
index 8dae38a..64d06fb 100644
--- a/includes/Search/SearchTextQueryBuilders.php
+++ b/includes/Search/SearchTextQueryBuilders.php
@@ -148,9 +148,7 @@
* @return \Elastica\Query\AbstractQuery
*/
public function buildMainQuery( array $fields, $queryString,
$phraseSlop ) {
- return $this->context->wrapInSaferIfPossible(
- $this->buildQueryString( $fields, $queryString,
$phraseSlop ),
- false );
+ return $this->buildQueryString( $fields, $queryString,
$phraseSlop );
}
/**
@@ -160,9 +158,7 @@
* @return \Elastica\Query\AbstractQuery
*/
public function buildHighlightQuery( array $fields, $queryString,
$phraseSlop ) {
- return $this->context->wrapInSaferIfPossible(
- $this->buildQueryString( $fields, $queryString,
$phraseSlop ),
- false );
+ return $this->buildQueryString( $fields, $queryString,
$phraseSlop );
}
/**
@@ -172,9 +168,7 @@
* @return \Elastica\Query\AbstractQuery
*/
public function buildRescoreQuery( array $fields, $queryString,
$phraseSlop ) {
- return $this->context->wrapInSaferIfPossible(
- $this->buildQueryString( $fields, $queryString,
$phraseSlop ),
- true );
+ return $this->buildQueryString( $fields, $queryString,
$phraseSlop );
}
/**
@@ -463,9 +457,7 @@
* @return \Elastica\Query\AbstractQuery
*/
public function buildHighlightQuery( array $fields, $queryString,
$phraseSlop ) {
- return $this->context->wrapInSaferIfPossible(
- $this->queryStringBuilder->buildQueryString( $fields,
$queryString, $phraseSlop, 'OR' ),
- false );
+ return $this->queryStringBuilder->buildQueryString( $fields,
$queryString, $phraseSlop, 'OR' );
}
/**
@@ -477,7 +469,6 @@
* @return \Elastica\Query\AbstractQuery
*/
public function buildRescoreQuery( array $fields, $queryString,
$phraseSlop ) {
- // already wrapped in safer
return $this->queryStringBuilder->buildRescoreQuery( $fields,
$queryString, $phraseSlop );
}
}
diff --git a/tests/jenkins/FullyFeaturedConfig.php
b/tests/jenkins/FullyFeaturedConfig.php
index 3f51632..b7d501f 100644
--- a/tests/jenkins/FullyFeaturedConfig.php
+++ b/tests/jenkins/FullyFeaturedConfig.php
@@ -27,10 +27,6 @@
$wgCirrusSearchUseExperimentalHighlighter = true;
$wgCirrusSearchOptimizeIndexForExperimentalHighlighter = true;
$wgCirrusSearchWikimediaExtraPlugin[ 'regex' ] = array( 'build', 'use' );
-$wgCirrusSearchWikimediaExtraPlugin[ 'safer' ] = array(
- 'phrase' => array(
- )
-);
$wgCirrusSearchQueryStringMaxDeterminizedStates = 500;
$wgCirrusSearchWikimediaExtraPlugin[ 'super_detect_noop' ] = true;
--
To view, visit https://gerrit.wikimedia.org/r/285464
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I47ac272c4d7cf2cd1e9ea15946fc87834f5b1358
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: es2.x
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: Gehel <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits