Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1025978
D43.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jun 13, 5:41 PM
Size
2 KB
Mime Type
text/x-diff
Expires
Sat, Jun 14, 5:41 PM (4 h, 6 m)
Engine
blob
Format
Raw Data
Handle
661409
Attached To
D43: INP-1409 - Don't calculate search relevance twice, when searching for one word only
D43.id.diff
View Options
Index: branches/5.2.x/core/kernel/db/cat_event_handler.php
===================================================================
--- branches/5.2.x/core/kernel/db/cat_event_handler.php
+++ branches/5.2.x/core/kernel/db/cat_event_handler.php
@@ -1318,10 +1318,14 @@
$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
}*/
+ if ( count($positive_words) > 1 ) {
+ $condition = $field . ' LIKE "%' . implode(' ', $positive_words) . '%"';
+ $revelance_parts[] = 'IF(' . $condition . ', ' . $weight_sum . ', 0)';
+ }
+
// search by partial word matches too
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
- foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
+ foreach ( $positive_words as $keyword ) {
+ $revelance_parts[] = 'IF(' . $field . ' LIKE "%' . $keyword . '%", ' . $weight . ', 0)';
}
}
Index: branches/5.2.x/core/units/categories/categories_event_handler.php
===================================================================
--- branches/5.2.x/core/units/categories/categories_event_handler.php
+++ branches/5.2.x/core/units/categories/categories_event_handler.php
@@ -2661,10 +2661,14 @@
$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
}*/
+ if ( count($positive_words) > 1 ) {
+ $condition = $field . ' LIKE "%' . implode(' ', $positive_words) . '%"';
+ $revelance_parts[] = 'IF(' . $condition . ', ' . $weight_sum . ', 0)';
+ }
+
// search by partial word matches too
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
- foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
+ foreach ( $positive_words as $keyword ) {
+ $revelance_parts[] = 'IF(' . $field . ' LIKE "%' . $keyword . '%", ' . $weight . ', 0)';
}
}
Event Timeline
Log In to Comment