search term alternatives added

This commit is contained in:
Michael 2024-01-30 11:14:41 +00:00
parent d6632bb0ea
commit 1e3cfca58d

View File

@ -40,6 +40,10 @@ class Engagement
{
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language'];
const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application'];
const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application',
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn', 'network:diaspora' => 'network:dspr',
'network:ostatus' => 'network:stat', 'network:ostatus' => 'network:stat', 'network:pumpio' => 'network:pump',
'network:discourse' => 'network:dscs', 'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
/**
* Store engagement data from an item array
@ -365,6 +369,10 @@ class Engagement
$fullTextSearch = preg_replace('~' . $search . ':(.[\w\*@\.-]+)~', $replace . ':$1', $fullTextSearch);
}
foreach (SELF::ALTERNATIVES as $search => $replace) {
$fullTextSearch = str_replace($search, $replace, $fullTextSearch);
}
foreach (self::KEYWORDS as $keyword) {
$fullTextSearch = preg_replace('~(' . $keyword . '):(.[\w\*@\.-]+)~', '"$1_$2"', $fullTextSearch);
}