r109817 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109816‎ | r109817 | r109818 >
Date:11:51, 23 January 2012
Author:sbachenberg
Status:deferred
Tags:
Comment:
* Added better Wildcard Support
Modified paths:
  • /trunk/extensions/SolrStore/SolrTalker.php (modified) (history)
  • /trunk/extensions/SolrStore/SpecialSolrSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SolrStore/SolrTalker.php
@@ -135,6 +135,15 @@
136136 if ( strpos( $value, ':' ) !== false ) { // Value conatins a ":" ?
137137 $parts = explode( ':', $value ); // Split the query part in key (parts[0]) and value (parts[1])
138138 $solrField = $this->findField( $parts[0] ); // Search for a Solr field for the key
 139+
 140+ //If we have a Wildcard Search transform Query to Lowercase for a Better Matching.
 141+ //Because on wildcard and fuzzy searches, no text analysis is performed on the search word
 142+ //and no Analyseres get used
 143+ if ( strpos( $parts[1], '*' ) !== false ) {
 144+ $parts[1] = strtolower( $parts[1] );
 145+ }
 146+
 147+ //If we have a solrField Match add a ':' (its the Lucene equivalent of '=' )
139148 if ( $solrField ) {
140149 $queryStr = $queryStr . ' ' . $solrField . ':' . $parts[1];
141150 } else {
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php
@@ -82,12 +82,12 @@
8383 $sk = $wgUser->getSkin ();
8484
8585
86 - $wgOut->setPageTitle ( wfMsg ( 'searchFieldSets' ) );
87 - $wgOut->setHTMLTitle ( wfMsg ( 'pagetitle', wfMsg ( 'searchFieldSets-title', 'SolrSearch: Select FieldSet' ) ) );
 86+ $wgOut->setPageTitle ( wfMsg ( 'solrstore-searchFieldSets-title' ) );
 87+ $wgOut->setHTMLTitle ( wfMsg ( 'pagetitle', wfMsg ( 'solrstore-searchFieldSets-title', 'SolrSearch: Select FieldSet' ) ) );
8888
8989 $wgOut->setArticleRelated ( false );
9090 $wgOut->addHtml ( '<div class="solrsearch-fieldset">' );
91 - $wgOut->addHtml ( wfMsg ( 'searchFieldSets-select' ) );
 91+ $wgOut->addHtml ( wfMsg ( 'solrstore-searchFieldSets-select' ) );
9292 $wgOut->addHtml ( '<ul>' );
9393
9494 //TODO: If no SearchSets exist, provide a shot Manual how to create some!
@@ -113,15 +113,15 @@
114114 $this->searchEngine = SearchEngine::create ();
115115 $search = & $this->searchEngine;
116116 $search->setLimitOffset ( $this->limit, $this->offset );
117 -
 117+
118118 $this->setupPage ( $fieldSet );
119 -
 119+
120120 $t = Title::newFromText ( $fieldSet->getName () );
121121
122 - //DO we have Title matches
 122+ //Do we have Title matches
123123 $fields = $fieldSet->getFields ();
124124
125 - //BUILD SOLR QUERY STRING FROM DA FIELDS
 125+ //Build Solr query string form the fields
126126 if ( isset ( $fields[ 'solrsearch' ] ) ) {
127127 $query = $fields[ 'solrsearch' ];
128128 } else {
@@ -236,7 +236,7 @@
237237 if ( $num || $this->offset ) {
238238 // Show the create link ahead
239239 $this->showCreateLink ( $t );
240 - $prevnext = wfViewPrevNext ( $this->offset, $this->limit, SpecialPage::getTitleFor ( 'SolrSearch/' . $fieldSet->{'mName'} ), wfArrayToCGI ( $fieldSet->{'mFields'} ), max ( $titleMatchesNum, $textMatchesNum ) < $this->limit );
 240+ $prevnext = wfViewPrevNext ( $this->offset, $this->limit, SpecialPage::getTitleFor ( 'SolrSearch/' . $fieldSet->mName ), wfArrayToCGI ( $fieldSet->mFields ), max ( $titleMatchesNum, $textMatchesNum ) < $this->limit );
241241 //$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
242242 wfRunHooks ( 'SpecialSolrSearchResults', array ( $fieldSet, &$titleMatches, &$textMatches ) );
243243 } else {
@@ -301,12 +301,12 @@
302302 /**
303303 *
304304 */
305 - protected function setupPage ( $fieldSet ) {
 305+ protected function setupPage ( $fieldSet, $results = false ) {
306306 global $wgOut;
307307
308308 if ( !empty ( $fieldSet ) ) {
309 - $wgOut->setPageTitle ( wfMsg ( 'searchresults' ) );
310 - $wgOut->setHTMLTitle ( wfMsg ( 'pagetitle', wfMsg ( 'searchresults-title', $fieldSet->getName () ) ) );
 309+ $wgOut->setPageTitle ( wfMsg ( 'solrsearch' ) .': '. $fieldSet->getName () );
 310+ $wgOut->setHTMLTitle ( wfMsg ( 'pagetitle', wfMsg ( 'solrsearch', $fieldSet->getName () ) ) );
311311 }
312312 $wgOut->setArticleRelated ( false );
313313 $wgOut->setRobotPolicy ( 'noindex,nofollow' );
@@ -320,7 +320,7 @@
321321 *
322322 * @param $matches SearchResultSet
323323 */
324 - protected function showMatches ( &$matches ) {
 324+ protected function showMatches ( $matches ) {
325325 global $wgContLang;
326326 wfProfileIn ( __METHOD__ );
327327

Status & tagging log