Merge branch 'develop' into enh/608-people-group-filter-limit

This commit is contained in:
Yuriy Bakhtin 2025-04-14 07:25:39 +02:00 committed by GitHub
commit 6913ededd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 10 deletions

View File

@ -14,6 +14,7 @@ HumHub Changelog
- Fix #7447: Update the comment counter when deleting a comment
- Fix #7456: Fix setting manager backwards compatibility
- Enh #7468: Remove deprecated widget `DataSaved`
- Enh #7493: Add possibility to define content search order via module config
- Enh #7494: Limit group filter on people page
1.17.3 (Unreleased)

View File

@ -11,6 +11,7 @@ namespace humhub\modules\content;
use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\content\search\driver\AbstractDriver;
use humhub\modules\content\search\driver\MysqlDriver;
use humhub\modules\content\search\SearchRequest;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
use Yii;
@ -95,17 +96,28 @@ class Module extends \humhub\components\Module
*/
public $publishScheduledInterval = 10;
/**
* @var string Class name of the searching driver
* @since 1.16
*/
public $searchDriverClass = MysqlDriver::class;
/**
* @var string Column name for ordering of the searching results
* @since 1.18
*/
public string $searchOrderBy = SearchRequest::ORDER_BY_SCORE;
/**
* @inheritdoc
*/
public function init()
{
parent::init(); // TODO: Change the autogenerated stub
parent::init();
$this->set('search', ['class' => $this->searchDriverClass]);
}
/**
* @param ContentContainerActiveRecord $container
* @return int

View File

@ -67,13 +67,16 @@ class SearchController extends Controller
*/
public function actionFind($keyword)
{
$driver = ContentSearchService::getDriver();
/* @var Module $module */
$module = Yii::$app->getModule('content');
$user = User::findOne(['id' => 1]);
$options = new SearchRequest([
'keyword' => $keyword,
'user' => User::findOne(['id' => 1]),
'orderBy' => $module->searchOrderBy,
]);
$options = new SearchRequest(['keyword' => $keyword, 'user' => $user]);
$searchResultSet = $driver->search($options);
$searchResultSet = ContentSearchService::getDriver()->search($options);
print "Number of hits: " . $searchResultSet->pagination->totalCount . "\n";

View File

@ -78,7 +78,7 @@ class ContentSearchProvider implements MetaSearchProviderInterface
$resultSet = $module->getSearchDriver()->search(new SearchRequest([
'keyword' => $this->getKeyword(),
'pageSize' => $maxResults,
'orderBy' => SearchRequest::ORDER_BY_SCORE,
'orderBy' => $module->searchOrderBy,
]));
$results = [];

View File

@ -43,7 +43,7 @@ class SearchRequest extends Model
public array $contentContainer = [];
public $orderBy = self::ORDER_BY_CREATION_DATE;
public string $orderBy = self::ORDER_BY_CREATION_DATE;
public ?SearchQuery $searchQuery = null;