1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-17 07:45:29 +08:00

限制全文搜索长度为50

This commit is contained in:
xiaochong0302 2025-02-26 10:19:27 +08:00
parent f5665bc94a
commit 77b7224901
4 changed files with 9 additions and 4 deletions

View File

@ -28,7 +28,7 @@ class Article extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);

View File

@ -28,7 +28,7 @@ class Course extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);

View File

@ -18,4 +18,9 @@ abstract class Handler extends LogicService
abstract function getRelatedQuery($query, $limit);
}
protected function handleKeywords($str)
{
return kg_substr($str, 0, 50, '');
}
}

View File

@ -28,7 +28,7 @@ class Question extends Handler
$paginator = new XunSearchPaginator([
'xs' => $searcher->getXS(),
'highlight' => $searcher->getHighlightFields(),
'query' => $params['query'],
'query' => $this->handleKeywords($params['query']),
'page' => $page,
'limit' => $limit,
]);