GithubHelp home page GithubHelp logo

Comments (9)

Adam-Mould avatar Adam-Mould commented on June 22, 2024 7

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.

nev7n avatar nev7n commented on June 22, 2024 2

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.

mikemike avatar mikemike commented on June 22, 2024 1

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.

flipersclub avatar flipersclub commented on June 22, 2024

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.

quangtam avatar quangtam commented on June 22, 2024

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.

xleedos avatar xleedos commented on June 22, 2024

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.

metrixinfo avatar metrixinfo commented on June 22, 2024

I can confirm the "FIX" works for Laravel 8.
Can we get this merged please?

from laravel-scout-mysql-driver.

msonowal avatar msonowal commented on June 22, 2024

@metrixinfo
Check the latest version 4

from laravel-scout-mysql-driver.

kespinosa avatar kespinosa commented on June 22, 2024

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.

image

from laravel-scout-mysql-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.