Comments (9)
Search works with WHERE when using LIKE mode. NATURAL_LANGUAGE seems to have the issue.
A quick fix for Natural Language: /src/Engines/MySQLEngine.php, Line 69
if ($mode->isFullText()) {
$query = $query->selectRaw(DB::raw($mode->buildSelectColumns($builder)), $params);
}
Change to...
if ($mode->isFullText()) {
$query = $query->selectRaw(DB::raw($mode->buildSelectColumns($builder)), [$params[0]]);
}
It seems the NaturalLanguage.php, buildParams() method appends the search query to the params array, however, when the MySQLEngine.php search() method detects an isFullText() mode it uses selectRaw and passes the params array as bindings in the wrong order. The above fix simply uses the zero-based item from the params array (which is the search query).
from laravel-scout-mysql-driver.
I've hit the same issue, downgrade didn't work for me. I'm on the following versions:
laravel/framework v6.18.11
laravel/scout v8.0.1
yab/laravel-scout-mysql-driver v3.0.0
I tried scout ^7.0 and mysql driver ^2.4 but still wasn't working.
from laravel-scout-mysql-driver.
Search works with WHERE when using LIKE mode. NATURAL_LANGUAGE seems to have the issue.
A quick fix for Natural Language: /src/Engines/MySQLEngine.php, Line 69
if ($mode->isFullText()) { $query = $query->selectRaw(DB::raw($mode->buildSelectColumns($builder)), $params); }
Change to...
if ($mode->isFullText()) { $query = $query->selectRaw(DB::raw($mode->buildSelectColumns($builder)), [$params[0]]); }
It seems the NaturalLanguage.php, buildParams() method appends the search query to the params array, however, when the MySQLEngine.php search() method detects an isFullText() mode it uses selectRaw and passes the params array as bindings in the wrong order. The above fix simply uses the zero-based item from the params array (which is the search query).
This fully fixes the issue. Any plans to merge this fix?
from laravel-scout-mysql-driver.
I've seen since 3.0 the ->where()
stopped working it started selecting the relevance in the SELECT
clause - however all the parameter were added to the binding so we had 4 bindings and 3 ?
in the query.
Downgrade Scout back down to 7.0 and the MySQL Driver down to 2.4 and it starts working again - though no support for Laravel 8.0
from laravel-scout-mysql-driver.
I've hit the same issue, downgrade didn't work for me. I'm on the following versions:
laravel/framework v6.18.11 laravel/scout v8.0.1 yab/laravel-scout-mysql-driver v3.0.0
I tried scout ^7.0 and mysql driver ^2.4 but still wasn't working.
Same with me!
from laravel-scout-mysql-driver.
For those struggling with this and looking for a quick fix: change /src/Engines/Modes/Mode.php, Line 43
from:
$queryString .= "$field $operator ? AND ";
To:
$queryString .= "$field $operator $value AND ";
:-)
from laravel-scout-mysql-driver.
I can confirm the "FIX" works for Laravel 8.
Can we get this merged please?
from laravel-scout-mysql-driver.
@metrixinfo
Check the latest version 4
from laravel-scout-mysql-driver.
i am using laravel 9 with laravel scout mysql 5.1 and this one does not work where. checking it i found that the ksort changes the order in which the query is assembled, passing the first text by placing it in the first where.
query builder
$Post = DscmsPost::search($request->q)->where('id_type_post',$this->tipo_post)->where('buscar',1)->paginate($this->page);
excerpt from the query being prepared:
"id_type_post = ? AND buscar = ? AND MATCH(description,img_preview,img_principal,keywords,permalink,post,post_preview,purl,subtitle,title) AGAINST(? IN NATURAL LANGUAGE MODE)
string to search: conveniencia
query that was executed>
select
count(*) as aggregate
from
`dscms_post`
where
id_type_post = 'convivencia'
AND buscar = 1
AND MATCH(
description,
img_preview,
img_principal,
keywords,
permalink,
post,
post_preview,
purl,
subtitle,
title
) AGAINST(1 IN NATURAL LANGUAGE MODE)
commenting line 68 of /src/Engines/MySQLEngine.php, where the param is ordered with the ksort, solves the problem.
from laravel-scout-mysql-driver.
Related Issues (20)
- Exception with Queue Exception: Please install the Algolia client: algolia/algoliasearch-client-php. in vendor/laravel/scout/src/EngineManager.php:59 HOT 1
- Callback method for modifying the db query not working
- How to exclude columns from the search?
- Search doesn't work with `with` or `load` HOT 2
- Class 'Yab\MySQLScout\Engines\Modes\' not found HOT 1
- Cache full text index fields HOT 2
- Query expansion not used in select columns
- Laravel 8 support HOT 3
- Question: highlight helper function
- Change "NATURAL LANGUAGE" search mode for models with unsupported columns like "int" HOT 1
- Inf and NaN cannot be JSON encoded HOT 1
- Laravel scout v9 support HOT 4
- Fallback not worked
- Emojis
- Laravel 9 Support
- Class 'Yab\MySQLScout\Engines\Modes\' not found
- Scout 10 Support HOT 1
- Indexing & Searching Relationships HOT 2
- Relevance is not accurate in boolean mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-scout-mysql-driver.