jenkins-bot has submitted this change and it was merged.
Change subject: Allow case sensitive search
......................................................................
Allow case sensitive search
Added checkbox to enable case sensitive search
Used Multi-field mapping to map 'content' field, once when it's analyzed
using Standard analyzer and once when it's analyzed using
analyzer similar to Standard analyzer with no lowercase and stop token filter.
Run "php scripts/ttmserver-export.php --reindex" to update index mapping.
Bug: T100013
Change-Id: I07ffa2f6eff2b905caaccca781fe438d91da65d7
---
M i18n/search/en.json
M i18n/search/qqq.json
M specials/SpecialSearchTranslations.php
M ttmserver/ElasticSearchTTMServer.php
4 files changed, 35 insertions(+), 4 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/search/en.json b/i18n/search/en.json
index 498febe..3f0b64f 100644
--- a/i18n/search/en.json
+++ b/i18n/search/en.json
@@ -26,5 +26,6 @@
"tux-sst-ellipsis-untranslated": "No translation",
"tux-sst-ellipsis-outdated": "Outdated translations",
"tux-sst-link-all-match": "Require all search words.",
- "tux-sst-match-message": "Showing translations which match any of the
search words. $1"
+ "tux-sst-match-message": "Showing translations which match any of the
search words. $1",
+ "tux-sst-case-sensitive": "Case sensitive"
}
diff --git a/i18n/search/qqq.json b/i18n/search/qqq.json
index 2f1f545..259c12c 100644
--- a/i18n/search/qqq.json
+++ b/i18n/search/qqq.json
@@ -29,5 +29,6 @@
"tux-sst-ellipsis-untranslated": "Used as label for an ellipsis to hide
untranslated messages.",
"tux-sst-ellipsis-outdated": "Used as label for an ellipsis to hide
outdated messages.",
"tux-sst-link-all-match": "Link to filter the results to match all
search words.",
- "tux-sst-match-message": "Used to inform users about an option to get
results for all search words. Parameters:\n* $1 - message
tux-sst-link-all-match."
+ "tux-sst-match-message": "Used to inform users about an option to get
results for all search words. Parameters:\n* $1 - message
tux-sst-link-all-match.",
+ "tux-sst-case-sensitive": "Label for a case sensitive checkbox"
}
diff --git a/specials/SpecialSearchTranslations.php
b/specials/SpecialSearchTranslations.php
index 3334e11..00864f3 100644
--- a/specials/SpecialSearchTranslations.php
+++ b/specials/SpecialSearchTranslations.php
@@ -72,6 +72,7 @@
$opts->add( 'grouppath', '' );
$opts->add( 'filter', '' );
$opts->add( 'match', '' );
+ $opts->add( 'case', '' );
$opts->add( 'limit', $this->limit );
$opts->add( 'offset', 0 );
@@ -500,11 +501,23 @@
$title = Html::hidden( 'title',
$this->getPageTitle()->getPrefixedText() );
$input = Xml::input( 'query', false, $query, $attribs );
$submit = Xml::submitButton( $this->msg( 'tux-sst-search' ),
array( 'class' => 'button' ) );
+
+ $nondefaults = $this->opts->getChangedValues();
+ $checkLabel = Xml::checkLabel(
+ $this->msg( 'tux-sst-case-sensitive' )->text(),
+ 'case',
+ 'tux-case-sensitive',
+ isset( $nondefaults['case'] )
+ );
+ $checkLabel = Html::openElement( 'div', array( 'class' =>
'tux-search-operators' ) ) .
+ $checkLabel .
+ Html::closeElement( 'div' );
+
$lang = $this->getRequest()->getVal( 'language' );
$language = is_null( $lang ) ? '' : Html::hidden( 'language',
$lang );
$form = Html::rawElement( 'form', array( 'action' => wfScript()
),
- $title . $input . $submit . $language
+ $title . $input . $submit . $checkLabel . $language
);
return $form;
diff --git a/ttmserver/ElasticSearchTTMServer.php
b/ttmserver/ElasticSearchTTMServer.php
index 130675c..b41448c 100644
--- a/ttmserver/ElasticSearchTTMServer.php
+++ b/ttmserver/ElasticSearchTTMServer.php
@@ -308,6 +308,10 @@
'type' => 'custom',
'tokenizer' =>
'standard',
'filter' => array(
'standard', 'lowercase', 'prefix_filter' )
+ ),
+ 'casesensitive' => array(
+ 'tokenizer' =>
'standard',
+ 'filter' => array(
'standard' )
)
)
)
@@ -353,6 +357,12 @@
'type' => 'string',
'index_analyzer' => 'prefix',
'search_analyzer' => 'standard',
+ 'term_vector' => 'yes'
+ ),
+ 'case_sensitive' => array(
+ 'type' => 'string',
+ 'index' => 'analyzed',
+ 'analyzer' => 'casesensitive',
'term_vector' => 'yes'
)
)
@@ -495,13 +505,17 @@
$fields = $highlights = array();
$terms = preg_split( '/\s+/', $queryString );
$match = $opts['match'];
+ $case = $opts['case'];
// Map each word in the query string with its corresponding
field
foreach ( $terms as $term ) {
$prefix = strstr( $term, '*', true );
- // For wildcard search
if ( $prefix ) {
+ // For wildcard search
$fields['content.prefix_complete'][] = $prefix;
+ } elseif ( $case === '1' ) {
+ // For case sensitive search
+ $fields['content.case_sensitive'][] = $term;
} else {
$fields['content'][] = $term;
}
@@ -645,6 +659,8 @@
$hl = $document->getHighlights();
if ( isset( $hl['content.prefix_complete'][0] ) ) {
$data['content'] =
$hl['content.prefix_complete'][0];
+ } elseif ( isset( $hl['content.case_sensitive'][0] ) ) {
+ $data['content'] =
$hl['content.case_sensitive'][0];
} elseif ( isset( $hl['content'][0] ) ) {
$data['content'] = $hl['content'][0];
}
--
To view, visit https://gerrit.wikimedia.org/r/212782
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I07ffa2f6eff2b905caaccca781fe438d91da65d7
Gerrit-PatchSet: 16
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Phoenix303 <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Nemo bis <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Phoenix303 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits