-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[plugin][search][content] give priority on result when title is matched #20197
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
120cb8e
[plugin][search][content] give priority on result when title is matched
alikon 157eb0c
Missed comma
alikon 56c07ef
Add relevance weighting according to number of words
ggppdk 5a2032a
Relevance by number of words in title only, removed introtext relevance
ggppdk 86bd9a1
Merge pull request #39 from ggppdk/patch-45
alikon f9fe6b1
Fix order string concatenation
ggppdk 77352d1
Merge pull request #41 from ggppdk/patch-60
alikon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,10 +273,18 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu | |
$case_when1 .= $query->concatenate(array($c_id, 'c.alias'), ':'); | ||
$case_when1 .= ' ELSE '; | ||
$case_when1 .= $c_id . ' END as catslug'; | ||
|
||
// Title priority | ||
$case_whenp = ' CASE WHEN '; | ||
$case_whenp .= $wheres2[0]; | ||
$case_whenp .= ' THEN 1 '; | ||
$case_whenp .= ' ELSE 0 '; | ||
$case_whenp .= ' END as priority'; | ||
|
||
$query->select('a.title AS title, a.metadesc, a.metakey, a.created AS created, a.language, a.catid') | ||
->select($query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text') | ||
->select('c.title AS section, ' . $case_when . ',' . $case_when1 . ', ' . '\'2\' AS browsernav') | ||
->select($case_whenp) | ||
->from('#__content AS a') | ||
->join('INNER', '#__categories AS c ON c.id=a.catid') | ||
->where( | ||
|
@@ -286,7 +294,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu | |
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')' | ||
) | ||
->group('a.id, a.title, a.metadesc, a.metakey, a.created, a.language, a.catid, a.introtext, a.fulltext, c.title, a.alias, c.alias, c.id') | ||
->order($order); | ||
->order('priority DESC, ' . $order); | ||
|
||
// Filter by language. | ||
if ($app->isClient('site') && JLanguageMultilang::isEnabled()) | ||
|
@@ -342,11 +350,18 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu | |
$case_when1 .= ' ELSE '; | ||
$case_when1 .= $c_id . ' END as catslug'; | ||
|
||
// Title priority | ||
$case_whenp = ' CASE WHEN '; | ||
$case_whenp .= $wheres2[0]; | ||
$case_whenp .= ' THEN 1 '; | ||
$case_whenp .= ' ELSE 0 '; | ||
$case_whenp .= ' END as priority'; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove tab |
||
$query->select( | ||
'a.title AS title, a.metadesc, a.metakey, a.created AS created, ' | ||
. $query->concatenate(array('a.introtext', 'a.fulltext')) . ' AS text,' | ||
. $case_when . ',' . $case_when1 . ', ' | ||
. 'c.title AS section, \'2\' AS browsernav' | ||
. 'c.title AS section, \'2\' AS browsernav, ' . $case_whenp | ||
); | ||
|
||
// .'CONCAT_WS("/", c.title) AS section, \'2\' AS browsernav' ); | ||
|
@@ -358,7 +373,7 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu | |
. 'AND (a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ') ' | ||
. 'AND (a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')' | ||
) | ||
->order($order); | ||
->order('priority DESC, ' . $order); | ||
|
||
// Join over Fields is no longer neded | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove tabs.