You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For feature parity, the function orderByDesc should be included. In my case I'm adding a relevance column to by database query, and sorting it descending. I'll include the code snippet how I have to do it and what would be good for feature parity in the 'Steps to reproduce' section.
Steps To Reproduce
This is how it has to be written now:
$articles = KnowledgeBaseArticle::search($request->search)
->query(function ($query) use ($request) {
$query->selectRaw(' knowledge_base_articles.*, MATCH(title) against(? IN NATURAL LANGUAGE MODE) * ? + MATCH(content) against(? IN NATURAL LANGUAGE MODE) * ? + MATCH(keywords) against(? IN NATURAL LANGUAGE MODE)* ? as relevance', [
$request->search,
KnowledgeBaseArticle::$title_weight,
$request->search,
KnowledgeBaseArticle::$content_weight,
$request->search,
KnowledgeBaseArticle::$keyword_weight,
]);
})
->orderBy('relevance', 'desc')
->paginate();
This is how I would like to write it to match other Eloquent usage:
$articles = KnowledgeBaseArticle::search($request->search)
->query(function ($query) use ($request) {
$query->selectRaw(' knowledge_base_articles.*, MATCH(title) against(? IN NATURAL LANGUAGE MODE) * ? + MATCH(content) against(? IN NATURAL LANGUAGE MODE) * ? + MATCH(keywords) against(? IN NATURAL LANGUAGE MODE)* ? as relevance', [
$request->search,
KnowledgeBaseArticle::$title_weight,
$request->search,
KnowledgeBaseArticle::$content_weight,
$request->search,
KnowledgeBaseArticle::$keyword_weight,
]);
})
->orderByDesc('relevance')
->paginate();
The text was updated successfully, but these errors were encountered:
Scout Version
10.11.8
Scout Driver
Database
Laravel Version
11.34
PHP Version
8.4.1
Database Driver & Version
MySQL 9.0.1 for macOS 14.6.1 on arm64 (Homebrew)
SDK Version
No response
Meilisearch CLI Version
No response
Description
For feature parity, the function
orderByDesc
should be included. In my case I'm adding a relevance column to by database query, and sorting it descending. I'll include the code snippet how I have to do it and what would be good for feature parity in the 'Steps to reproduce' section.Steps To Reproduce
This is how it has to be written now:
This is how I would like to write it to match other Eloquent usage:
The text was updated successfully, but these errors were encountered: