Index: trunk/extensions/SolrStore/SolrTalker.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * |
7 | 7 | * @ingroup SolrStore |
8 | 8 | * @file |
9 | | - * @author Simon Bachenberg |
| 9 | + * @author Simon Bachenberg, Sascha Schueller |
10 | 10 | */ |
11 | 11 | |
12 | 12 | /** |
— | — | @@ -91,13 +91,13 @@ |
92 | 92 | $stop = false; |
93 | 93 | |
94 | 94 | foreach ( $xml->lst as $item ) { |
95 | | - if ( $item['name'] == 'fields' ) { |
| 95 | + if ( $item[ 'name' ] == 'fields' ) { |
96 | 96 | foreach ( $item->lst as $field ) { |
97 | 97 | if ( count( $field ) > 2 ) { |
98 | | - $dynamicBase = substr( $field->str[2], 1 ); // Get the dynamic base of the field eg. "*_dtmax" |
99 | | - $newField = str_replace( $dynamicBase, '', $field['name'] ); // Get the field name without the dynamicbase |
| 98 | + $dynamicBase = substr( $field->str[ 2 ], 1 ); // Get the dynamic base of the field eg. "*_dtmax" |
| 99 | + $newField = str_replace( $dynamicBase, '', $field[ 'name' ] ); // Get the field name without the dynamicbase |
100 | 100 | if ( strcasecmp( str_replace( ' ', '_', $newField ), $searchField ) == 0 ) { // Replace all spaces with underscore for better matching |
101 | | - $result = trim( $field['name'] ); |
| 101 | + $result = trim( $field[ 'name' ] ); |
102 | 102 | if ( stripos( $dynamicBase, 'max' ) && stripos( $sort, 'desc' ) ) { |
103 | 103 | // For descending sorting use the MaX value field |
104 | 104 | continue 2; // we got the right field, stop it! |
— | — | @@ -107,12 +107,12 @@ |
108 | 108 | } elseif ( !stripos( $dynamicBase, 'min' ) && !stripos( $dynamicBase, 'max' ) ) { |
109 | 109 | continue 2; // we got the right field, stop it! |
110 | 110 | } |
111 | | - } elseif ( strcasecmp( str_replace( ' ', '_', $field['name'] ), $searchField ) == 0 ) { // Replace all spaces with underscore for better matching |
| 111 | + } elseif ( strcasecmp( str_replace( ' ', '_', $field[ 'name' ] ), $searchField ) == 0 ) { // Replace all spaces with underscore for better matching |
112 | 112 | $result = trim( $searchField ); |
113 | 113 | } |
114 | 114 | } else { |
115 | | - if ( strcasecmp( trim( $field['name'] ), trim( $searchField ) ) == 0 ) { |
116 | | - $result = trim( $field['name'] ); |
| 115 | + if ( strcasecmp( trim( $field[ 'name' ] ), trim( $searchField ) ) == 0 ) { |
| 116 | + $result = trim( $field[ 'name' ] ); |
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
— | — | @@ -135,19 +135,22 @@ |
136 | 136 | foreach ( $queryParts as $value ) { |
137 | 137 | if ( strpos( $value, ':' ) !== false ) { // Value conatins a ":" ? |
138 | 138 | $parts = explode( ':', $value ); // Split the query part in key (parts[0]) and value (parts[1]) |
139 | | - $solrField = $this->findField( $parts[0] ); // Search for a Solr field for the key |
| 139 | + $solrField = $this->findField( $parts[ 0 ] ); // Search for a Solr field for the key |
140 | 140 | //If we have a Wildcard Search transform Query to Lowercase for a Better Matching. |
141 | 141 | //Because on wildcard and fuzzy searches, no text analysis is performed on the search word |
142 | 142 | //and no Analyseres get used |
143 | | - if ( strpos( $parts[1], '*' ) !== false ) { |
144 | | - $parts[1] = strtolower( $parts[1] ); |
| 143 | + if ( strpos( $parts[ 1 ], '*' ) !== false ) { |
| 144 | + $parts[ 1 ] = strtolower( $parts[ 1 ] ); |
| 145 | + //If we got an "AND" or an "OR" we have to write them uppercase |
| 146 | + $parts[ 1 ] = str_replace( ' and ', ' AND ', $parts[ 1 ] ); |
| 147 | + $parts[ 1 ] = str_replace( ' or ', ' OR ', $parts[ 1 ] ); |
145 | 148 | } |
146 | 149 | |
147 | 150 | //If we have a solrField Match add a ':' (its the Lucene equivalent of '=' ) |
148 | 151 | if ( $solrField ) { |
149 | | - $queryStr = $queryStr . ' ' . $solrField . ':' . $parts[1]; |
| 152 | + $queryStr = $queryStr . ' ' . $solrField . ':' . $parts[ 1 ]; |
150 | 153 | } else { |
151 | | - $queryStr = $queryStr . ' ' . $parts[0] . ' ' . $parts[1]; |
| 154 | + $queryStr = $queryStr . ' ' . $parts[ 0 ] . ' ' . $parts[ 1 ]; |
152 | 155 | } |
153 | 156 | } else { |
154 | 157 | $queryStr = $queryStr . ' ' . $value; |
— | — | @@ -174,8 +177,8 @@ |
175 | 178 | foreach ( $queryParts as $part ) { |
176 | 179 | if ( stripos( $part, '::' ) ) { |
177 | 180 | $parts = explode( '::', $part ); // Split the query part in key (parts[0]) and value (parts[1]) |
178 | | - $parts[0] = $this->findField( $parts[0] ); // Search for a Solr field for the key |
179 | | - $queryStr = $queryStr . ' ' . $parts[0] . ':' . $parts[1]; // Build query string |
| 181 | + $parts[ 0 ] = $this->findField( $parts[ 0 ] ); // Search for a Solr field for the key |
| 182 | + $queryStr = $queryStr . ' ' . $parts[ 0 ] . ':' . $parts[ 1 ]; // Build query string |
180 | 183 | } elseif ( stripos( $part, ':' ) ) { |
181 | 184 | $queryStr = $queryStr . ' category' . substr( $part, stripos( $part, ':' ) ); |
182 | 185 | } else { |
— | — | @@ -218,7 +221,7 @@ |
219 | 222 | $ch = curl_init(); |
220 | 223 | |
221 | 224 | $url = str_replace( ' ', '+', $url ); |
222 | | - if ($wgSolrDebug){ |
| 225 | + if ( $wgSolrDebug ) { |
223 | 226 | echo $url; |
224 | 227 | } |
225 | 228 | curl_setopt( $ch, CURLOPT_URL, $url ); |
Index: trunk/extensions/SolrStore/SpecialSolrSearch.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * This is the SpecialPage, displaying the SearchSets and Results |
8 | 8 | * |
9 | 9 | * @defgroup SolrStore |
10 | | - * @author Simon Bachenberg |
| 10 | + * @author Simon Bachenberg, Sascha Schueller |
11 | 11 | */ |
12 | 12 | class SpecialSolrSearch extends SpecialPage { |
13 | 13 | |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | |
145 | 145 | if ( !empty( $query ) ) { |
146 | 146 | //Add the Extra query string plus a space to the end of the query |
147 | | - $query .=' '.trim($fieldSet->getQuery()); |
| 147 | + $query .=' ' . trim( $fieldSet->getQuery() ); |
148 | 148 | } |
149 | 149 | // TODO: More Exception Handling for Format Exceptions |
150 | 150 | try { |
— | — | @@ -447,7 +447,7 @@ |
448 | 448 | // Search engine doesn't report scoring info |
449 | 449 | $score = ''; |
450 | 450 | } else { |
451 | | - $percent = sprintf( '%2.1f', $result->getScore() * 100 ); |
| 451 | + $percent = sprintf( '%2.1f', $result->getScore() * 10 ); // * 100 |
452 | 452 | $score = wfMsg( 'search-result-score', $wgLang->formatNum( $percent ) ) . ' - '; |
453 | 453 | } |
454 | 454 | |