Phuedx has uploaded a new change for review.
https://gerrit.wikimedia.org/r/173289
Change subject: WIP Allow limiting morelike to pages with WikiGrok claims
......................................................................
WIP Allow limiting morelike to pages with WikiGrok claims
This change renames the "morelikethiswithwikibase:" prefix, which was
introduced in Ic7eec0027a1a6216a02c87c5810a99dd3dd9b3e9, to
"morelikethiswithwikigrok:".
Like the initial implementation, the prefix works like the "morelike:"
prefix, except that items without WikiGrok claims are filtered out.
TODO:
Unlike the initial implementation, WikiGrok claims are added to the page
as a JavaScript configuration variable, called "wgWikiGrokCampaigns",
when the OutputPageParserOutput hook fires.
Change-Id: I49a183cecf9f4d9d67eb1521824f455c0963d4d5
---
M includes/CirrusSearch.php
M includes/Searcher.php
2 files changed, 7 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/89/173289/1
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index 45451a0..b252887 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -27,7 +27,7 @@
*/
class CirrusSearch extends SearchEngine {
const MORE_LIKE_THIS_PREFIX = 'morelike:';
- const MORE_LIKE_THIS_JUST_WIKIBASE_PREFIX = 'morelikewithwikibase:';
+ const MORE_LIKE_THIS_JUST_WIKIGROK_PREFIX = 'morelikewithwikigrok:';
/**
* @var string The last prefix substituted by replacePrefixes.
@@ -98,9 +98,9 @@
if ( substr( $term, 0, strlen( self::MORE_LIKE_THIS_PREFIX ) )
=== self::MORE_LIKE_THIS_PREFIX ) {
$term = substr( $term, strlen(
self::MORE_LIKE_THIS_PREFIX ) );
$status = $this->moreLikeThis( $term, $searcher,
Searcher::MORE_LIKE_THESE_NONE );
- } else if ( substr( $term, 0, strlen(
self::MORE_LIKE_THIS_JUST_WIKIBASE_PREFIX ) ) ===
self::MORE_LIKE_THIS_JUST_WIKIBASE_PREFIX ) {
- $term = substr( $term, strlen(
self::MORE_LIKE_THIS_JUST_WIKIBASE_PREFIX ) );
- $status = $this->moreLikeThis( $term, $searcher,
Searcher::MORE_LIKE_THESE_ONLY_WIKIBASE );
+ } else if ( substr( $term, 0, strlen(
self::MORE_LIKE_THIS_JUST_WIKIGROK_PREFIX ) ) ===
self::MORE_LIKE_THIS_JUST_WIKIGROK_PREFIX ) {
+ $term = substr( $term, strlen(
self::MORE_LIKE_THIS_JUST_WIKIGROK_PREFIX ) );
+ $status = $this->moreLikeThis( $term, $searcher,
Searcher::MORE_LIKE_THESE_ONLY_WIKIGROK );
} else {
$highlightingConfig =
FullTextResultsType::HIGHLIGHT_ALL;
if ( $request ) {
diff --git a/includes/Searcher.php b/includes/Searcher.php
index c6d2207..42e71f9 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -46,7 +46,7 @@
const HIGHLIGHT_POST = '</span>';
const HIGHLIGHT_REGEX = '/<span class="searchmatch">.*?<\/span>/';
const MORE_LIKE_THESE_NONE = 0;
- const MORE_LIKE_THESE_ONLY_WIKIBASE = 1;
+ const MORE_LIKE_THESE_ONLY_WIKIGROK = 1;
/**
* Maximum title length that we'll check in prefix and keyword searches.
@@ -778,7 +778,7 @@
* @param array(Title) $titles title of articles to search for
* @param int $options bitset of options:
* MORE_LIKE_THESE_NONE
- * MORE_LIKE_THESE_ONLY_WIKIBASE - filter results to only those
containing wikibase items
+ * MORE_LIKE_THESE_ONLY_WIKIGROK - filter results to only those
containing wikibase items
* @return Status(ResultSet)
*/
public function moreLikeTheseArticles( $titles, $options =
Searcher::MORE_LIKE_THESE_NONE ) {
@@ -813,7 +813,7 @@
$this->query->setFields( array( 'text' ) );
$idFilter = new \Elastica\Filter\Ids( null, $pageIds );
$this->filters[] = new \Elastica\Filter\BoolNot( $idFilter );
- if ( $options & Searcher::MORE_LIKE_THESE_ONLY_WIKIBASE ) {
+ if ( $options & Searcher::MORE_LIKE_THESE_ONLY_WIKIGROK ) {
$this->filters[] = new \Elastica\Filter\Exists(
'wikibase_item' );
}
--
To view, visit https://gerrit.wikimedia.org/r/173289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I49a183cecf9f4d9d67eb1521824f455c0963d4d5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits