GithubHelp home page GithubHelp logo

yabhq / laravel-scout-mysql-driver Goto Github PK

View Code? Open in Web Editor NEW
522.0 16.0 110.0 94 KB

Laravel Scout MySQL Driver

License: MIT License

PHP 98.31% Dockerfile 0.57% Makefile 1.13%
laravel-scout laravel laravel-5-package mysql

laravel-scout-mysql-driver's Introduction

Laravel Scout MySQL Driver

Search Eloquent Models using MySQL FULLTEXT Indexes or WHERE LIKE '%:search%' statements.

  1. Installation
  2. Usage
  3. Modes
  4. Console Command
  5. Configuration

Installation

Note: Any Models you plan to search using this driver must use a MySQL MyISAM or InnoDB table.

If you haven't already you should install Laravel Scout to your project and apply the Laravel\Scout\Searchable trait to any Eloquent models you would like to make searchable.

Install this package via Composer

composer require yab/laravel-scout-mysql-driver

Next if you are using laravel version 5.4, include the following ServiceProvider to the Providers array in config/app.php

        /*
         * Package Service Providers...
         */
        Yab\MySQLScout\Providers\MySQLScoutServiceProvider::class,

Append the default configuration to config/scout.php

    'mysql' => [
        'mode' => 'NATURAL_LANGUAGE',
        'model_directories' => [app_path()],
        'min_search_length' => 0,
        'min_fulltext_search_length' => 4,
        'min_fulltext_search_fallback' => 'LIKE',
        'query_expansion' => false
    ]

Set SCOUT_DRIVER=mysql in your .env file

Please note this Laravel Scout driver does not need to update any indexes when a Model is changed as this is handled natively by MySQL. Therefore you can safely disable queuing in config/scout.php.

    /*
    |--------------------------------------------------------------------------
    | Queue Data Syncing
    |--------------------------------------------------------------------------
    |
    | This option allows you to control if the operations that sync your data
    | with your search engines are queued. When this is set to "true" then
    | all automatic data syncing will get queued for better performance.
    |
    */

    'queue' => false,

In addition there is no need to use the php artisan scout:import command. However, if you plan to use this driver in either NATURAL_LANGUAGE or BOOLEAN mode you should first run the provided console command to create the needed FULLTEXT indexes.

Usage

Simply call the search() method on your Searchable models:

$beers = App\Drink::search('beer')->get();

Or With pagination:

$beers = App\Drink::search('beer')->paginate(15);

Simple constraints can be applied using the where() builder method (each additional WHERE will be applied using AND).

$beers = App\Drink::search('beer')->where('in_stock', 1)->get();

The following operators can be applied to the WHERE statements: <> != = <= < >= > (= will be used if no operator is specified)

$beers = App\Drink::search('beer')->where('abv >', 10)->get();

For more usage information see the Laravel Scout Documentation.

Modes

This driver can perform different types of search queries depending on the mode set in the scout.mysql.mode Laravel configuration value. Currently 4 different modes are supported NATURAL_LANGUAGE,BOOLEAN,LIKE and LIKE_EXPANDED.

NATURAL_LANGUAGE and BOOLEAN Modes

In NATURAL_LANGUAGE and BOOLEAN mode the driver will run MySQL WHERE MATCH() AGAINST() queries in the respective modes.

Both modes search queries will include all of Model's FULLTEXT compatible fields (CHAR,VARCHAR,TEXT) returned from the Model's toSearchableArray() method. It is required to have a FULLTEXT index for these fields. You can create this index using the provided console command.

For example running a search on a POST model with the following database structure:

column name type
id int(10) UN AI PK
content VARCHAR(255)
meta TEXT

would produce the following query in NATURAL_LANGUAGE mode:

select * from `posts` where MATCH(content,meta) AGAINST(? IN NATURAL LANGUAGE MODE)

and the following query in BOOLEAN mode:

select * from `posts` where MATCH(content,meta) AGAINST(? IN BOOLEAN MODE)

Operators for BOOLEAN mode should be passed as part of the search string.

For more information see the MySQL's Full-Text Search Functions documentation.

LIKE and LIKE_EXPANDED Modes

LIKE and LIKE_EXPANDED modes will run WHERE LIKE %?% queries that will include all of the Model's fields returned from toSearchableArray(). LIKE_EXPANDED mode will query each field using each individual word in the search string.

For example running a search on a Customer model with the following database structure:

column name type
id int(10) UN AI PK
first_name VARCHAR(255)
last_name VARCHAR(255)

would produce the following query in LIKE mode given the search string "John":

SELECT * FROM `customers` WHERE (`id` LIKE '%John%' OR `first_name` LIKE '%John%' OR `last_name` LIKE '%JOHN%')

and the following query in LIKE_EXPANDED mode given the search string "John Smith":

SELECT * FROM `customers` WHERE (`id` LIKE '%John%' OR `id` LIKE '%Smith%' OR `first_name` LIKE '%John%' OR `first_name` LIKE '%Smith%' OR `last_name` LIKE '%John%' OR `last_name` LIKE '%Smith%')

Console Command

The command php artisan scout:mysql-index {model?} is included to manage the FULLTEXT indexes needed for NATURAL_LANGUAGEand BOOLEAN modes.

If the model parameter is omitted the command will run with all Model's with the Laravel\Scout\Searchable trait and a MySQL connection within the directories defined in the scout.mysql.model_directories Laravel configuration value.

Creating Indexes

Pass the command a Model to create a FULLTEXT index for all of the Model's FULLTEXT compatible fields (CHAR,VARCHAR,TEXT) returned from the Model's toSearchableArray() method. The index name will be the result of the Model's searchableAs() method.

If an index already exists for the Model and the Model contains new searchable fields not in the existing index the index will be dropped and recreated.

php artisan scout:mysql-index App\\Post

Dropping index

Pass the -D or --drop options to drop an existing index for a Model.

php artisan scout:mysql-index App\\Post --drop

Configuration

Behavior can be changed by modifying the scout.mysql Laravel configuration values.

  • scout.mysql.mode - The mode used to determine how the driver runs search queries. Acceptable values are NATURAL_LANGUAGE,BOOLEAN,LIKE and LIKE_EXPANDED.

  • scout.mysql.model_directories - If no model parameter is provided to the included php artisan scout:mysql-index command the directories defined here will be searched for Model's with the Laravel\Scout\Searchable trait and a MySQL connection.

  • scout.mysql.min_search_length - If the length of a search string is smaller then this value no search queries will run and an empty Collection will be returned.

  • scout.mysql.min_fulltext_search_length - If using NATURAL_LANGUAGE or BOOLEAN modes and a search string's length is less than this value the driver will revert to a fallback mode. By default MySQL requires a search string length of at least 4 to to run FULLTEXT queries. For information on changing this see the MySQL's Fine-Tuning MySQL Full-Text Search documentation.

  • scout.mysql.min_fulltext_search_fallback - The mode that will be used as a fallback when the search string's length is less than scout.mysql.min_fulltext_search_length in NATURAL_LANGUAGE or BOOLEAN modes. Acceptable values are LIKE and LIKE_EXPANDED.

  • scout.mysql.query_expansion - If set to true MySQL query expansion will be used in search queries. Only applies if using NATURAL_LANGUAGE mode. For more information see MySQL's Full-Text Searches with Query Expansion documentation.

laravel-scout-mysql-driver's People

Contributors

alpineglow avatar antriver avatar austinw avatar blaise-zaga avatar boboldehampsink avatar buchin avatar casperlaitw avatar christhompsontldr avatar cmaerz avatar damiantw avatar dariusiii avatar djekl avatar freezer278 avatar gkarugi avatar gmartinez avatar hmazter avatar jbardnz avatar jonathan-bird avatar marky291 avatar mattdfloyd avatar mbardelmeijer avatar mlantz avatar msonowal avatar ozankurt avatar romanmiranda avatar sbarbat avatar tarreislam avatar taylornotwell avatar thekonz avatar tomlankhorst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-scout-mysql-driver's Issues

Issue with indexing dates

Hi, my model has two MySQL date columns, start_date and end_date stored as "Y-m-d", in addition to Laravel's created_at and updated_at.

In order for me to get them to display on the front end I need this line in my model:

protected $dates = ['start_date', 'end_date'];

I'm trying to integrate Laravel Scout with this driver but am running into an issue during index:

Creating index for App\Models\Report... 
In Carbon.php line 582:                 
  Data missing                          

Likewise, when trying to search the model I get this:

InvalidArgumentException
Data missing

The source of the problem seems to be these setters:

    /*
     * Convert start date to valid timestamp before adding to database.
     *
     * @param $value
     */
    public function setStartDateAttribute($value)
    {
        $this->attributes['start_date'] = Carbon::createFromFormat('m/d/Y', $value);
    }

    /**
     * Convert end date to valid timestamp before adding to database.
     *
     * @param $value
     */
    public function setEndDateAttribute($value)
    {
        $this->attributes['end_date'] = Carbon::createFromFormat('m/d/Y', $value);
    }

Which I use because the date picker data is flashed in the format m/d/Y and then converted on persistence.

How can I get around this?

Issue with multiple where on same column

$searchText = 'test';
$query_builder = User::search($searchText);
$query_builder->where('a <=', 10);
$query_builder->where('b >=', 100);

it's correct, result :

select count(*) as aggregate from `beats` where a< '10' AND b> '100' 
AND MATCH(title) AGAINST('test' IN NATURAL LANGUAGE MODE)

but if i do

$searchText = 'test';
$query_builder = User::search($searchText);
$query_builder->where('a <=', 10);
$query_builder->where('a >=', 100);

result

"Illuminate\Database\QueryException

SQLSTATE[HY093]: Invalid parameter number (SQL: select count(*) as aggregate 
from `users` where a<= 100 AND a>= test AND MATCH(title) AGAINST(? IN NATURAL LANGUAGE MODE))

Getting "Undefined property: Laravel\\Scout\\Builder::$offset"

Getting "Undefined property: Laravel\\Scout\\Builder::$offset"
on line 73 in damiantw/laravel-scout-mysql-driver/src/Engines/MySQLEngine.php which reads:
if($this->builder->offset) {

This happens when i do: Child::search($q)->get();

Using PHP 7.0.8 in homestead

Search within multiple tables/models

Is it possible to search within multiple tables/models and get the result in a singel collection? I can't find something about it in the manual.

Invalid parameter number with LIKE mode

When I change to LIKE mode I'm getting an error showing that there are too many parameters.

SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

"select count(*) as aggregate from recurring_profiles where account_id = :account_id AND (id LIKE :_search0 OR account_id LIKE :_search1 OR title LIKE :_search2) and recurring_profiles.deleted_at is null",
[
1,
"%liabiliti%",
"%liabiliti%",
"%liabiliti%",
"%liabiliti%"
],

Laravel 5.4 support

Would love to see Laravel 5.4 support.

Currently this happens when running
composer require damiantw/laravel-scout-mysql-driver

You gets
damiantw/laravel-scout-mysql-driver v1.0.6 requires laravel/framework 5.3.*

Include softDeletes in search results

Is there a way to include soft deleted models in the search results?

I tried several approached found around the net with no luck.

Maybe this is related to #17?

QueryException

Hello. I use Laravel 5.3 upgraded to 5.4. I have PHP7 version and Mysql. I run my app on Ubuntu, apache2 machine.
I want search users using your package, when I try with only name (or last name) it's ok, but when I write name and last name, for example John Smith, I get issue.

(2/2) QueryExceptionSQLSTATE[HY000]: General error: 1191 Can't find FULLTEXT index matching the column list (SQL: select count(*) as aggregate from ys_users where MATCH(name,last_name,login,password,email,mobile,skype,street,city,file) AGAINST(John Smith IN BOOLEAN MODE))

Declaration of map function

I have just updated to latest version of laravel/scout (5.0.3) and aravel-scout-mysql-driver (2.0.6) and i have started receiving the following error:

Declaration of Yab\MySQLScout\Engines\MySQLEngine::map(Laravel\Scout\Builder $builder, $model) must be compatible with Laravel\Scout\Engines\Engine::map(Laravel\Scout\Builder $builder, $results, $model)

Search on relationships

Hi there, I was using elasticsearch driver and I had no trouble indexing relationships
like this:

public function toSearchableArray()
{
    $array = $this->toArray();

    // Customize array...

    $array = remove_from_array($array, $this->appends);

    $extra_data = [];

    if ($this->company) {
        $extra_data['company_name'] = $this->company->name;
    }

    return array_merge($array, $extra_data);
}

But have no idea how to achieve the same with mysql driver

Limit field when indexing

I have an old table with lot's of fulltext capable fields and cannot remove them. When I am trying to add the indexes I get the response that a maximum of 16 fields are allowed while I have 17. Only three of them contain real data to search on.

It would be nice to have a possibility to limit the fields to create an fulltext search index on and eventually to search in.

A nice way to do this is by adding a $searchable array to the model like this:

use Laravel\Scout\Searchable;

class Product extends Model
{
    use Searchable;
    
    protected $searchable = [
        'menu',
        'title',
        'text'
    ];
    ...
}

What's Happening? Cant install it in my project.

`Using version ^2.0 for yab/laravel-scout-mysql-driver
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install yab/laravel-scout-mysql-driver v2.0.3
- Installation request for laravel/scout (locked at v5.0.3, required as ^5.0) -> satisfiable by laravel/scout[v5.0.3].
- Conclusion: remove laravel/framework v5.6.31
- Conclusion: don't install laravel/framework v5.6.31
- yab/laravel-scout-mysql-driver v2.0.0 requires laravel/framework 5.3.|5.4. -> satisfiable by laravel/framework[5.3.x-dev, 5.4.x-dev].
- yab/laravel-scout-mysql-driver v2.0.1 requires laravel/framework 5.3.|5.4.|5.5.* -> satisfiable by laravel/framework[5.3.x-dev, 5.4.x-dev, 5.5.x-dev].
- yab/laravel-scout-mysql-driver v2.0.2 requires laravel/framework 5.3.|5.4.|5.5.* -> satisfiable by laravel/framework[5.3.x-dev, 5.4.x-dev, 5.5.x-dev].
- Can only install one of: laravel/framework[5.3.x-dev, v5.6.31].
- Can only install one of: laravel/framework[5.4.x-dev, v5.6.31].
- Can only install one of: laravel/framework[5.5.x-dev, v5.6.31].
- Installation request for laravel/framework (locked at v5.6.31, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.31].
- Installation request for yab/laravel-scout-mysql-driver ^2.0 -> satisfiable by yab/laravel-scout-mysql-driver[v2.0.0, v2.0.1, v2.0.2, v2.0.3].

Installation failed, reverting ./composer.json to its original content.`

UTF8 problem

can't do a search in Persian or Arabic

SQLSTATE[HY000]: General error: 1271 Illegal mix of collations for operation 'like' (SQL: select count(*) as aggregate from items where (idLIKE %سلام% ORtitleLIKE %سلام% ORintroLIKE %سلام% ORdescriptionLIKE %سلام% ORthumbnailLIKE %سلام% ORimagesLIKE %سلام% ORpriceLIKE %سلام% ORstatusLIKE %سلام% ORuser_idLIKE %سلام% ORcreated_atLIKE %سلام% ORupdated_atLIKE %سلام% ORdeleted_atLIKE %سلام% ORslugLIKE %سلام%) anditems.deleted_at is null)

Search query Looking for '__soft_deleted' column

My test returns this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '__soft_deleted' in 'where clause' (SQL: select count(*) as aggregate from `posts` where __soft_deleted = 0 AND MATCH(country,state,city,address,patient_avatar) AGAINST(Ismail IN NATURAL LANGUAGE MODE) and `posts`.`deleted_at` is null)

Any suggestion to solve this problem?

NB: I am using scout for first time.

Cant require it with Laravel 5.7

Getting this error:

Problem 1
    - Conclusion: don't install yab/laravel-scout-mysql-driver v2.0.5
    - Installation request for laravel/scout (locked at v5.0.3, required as ^5.0) -> satisfiable by laravel/scout[v5.0.3].
    - Conclusion: remove laravel/framework v5.7.0
    - Conclusion: don't install laravel/framework v5.7.0

Laravel 5.8

I'm really into using Laravel 5.8 with this package :D

Append score or filter on score?

Is there any way to include or filter on the actual score?

MATCH(contents) AGAINST("TEST STRING" IN NATURAL LANGUAGE MODE)

from the WHERE clause can be repeated in the SELECT with an alias to get the score (this has no overhead according to MySQL docs)

MATCH(contents) AGAINST("TEST STRING" IN NATURAL LANGUAGE MODE) AS score

which also allows you to add something like "WHERE score > 2"

I tried looking through the code, but I can't figure out how to get to the QueryBuilder instance (for addSelect() method), but it seems Scout Builder doesn't expose this.

Any thoughts?

edit: Just want to add, that the main issue here is that all rows are always returned even ones that have a score of 0. This is not ideal.

LIKE mode not found

During the development everything was fine. But after deployment, I'm getting this error:

'Yab\MySQLScout\Engines\Modes\LIke' not found

First, I got this error on database migrations. Then i commented use Searchable lines on my models and successfully migrated. After migration I've remove the comment and indexed my models. But when I'm trying to search a query, I'm still getting this error.

Here is my scout configuration

'mysql' => [ 'mode' => 'NATURAL_LANGUAGE', 'model_directories' => [app_path()], 'min_search_length' => 1, 'min_fulltext_search_length' => 1, 'min_fulltext_search_fallback' => 'LIKE', 'query_expansion' => false ],

My deadline is in 24 hours. So, any help will be appreciated.

Need to add % myself when doing like/like_expanded?

Title is self explanatory, but yeah, let's say I'm making a search in an artist table, looking for Lady Gaga.

Artist::search('gag')->get() returns nothing.
Artist::search('%gag%')->get() returns the row with Lady Gaga  in it.

My understanding from your doc was that it was made automatically, but it's not?

Laravel 5.5 support

5.5 will hit fairly soon. Any plans on adding it to the semver in the composer.json ?
It seems to be working perfectly fine under 5.5 already, but my tests are probably inadequate.

Limitation of results by relevance

Hi,
is it posible to limit of results by relevance?
Something like:

SELECT *, MATCH(name,title,text) AGAINST('some text' IN BOOLEAN MODE) AS relevance 
FROM `search_articles`
WHERE MATCH(name,title,text) AGAINST('some text' IN BOOLEAN MODE) 
HAVING relevance > 10 
ORDER BY relevance DESC

Thanks

Searching Model with Accessor

I'm not sure if this would be more a Scout limitation or the driver here.

I have a model that contains a table for a phone number. Unfortunately I'm working with an existing database where they did not standardize these fields, as such phone numbers can contain dashes, spaces, parenthesis, etc.

So as a result I'm using a Accessor on this:

public function getPhoneAttribute($value)
    {
        return preg_replace("/[^A-Za-z0-9]/", "", $value);
    }

However, when utilizing search it seems to ignore this and still looks for the original value with dashes, etc.

Eloquent with GlobalScope have Exception

I have a model Post use GlobalScope

    protected static function boot()
    {
        parent::boot();

       static::addGlobalScope('status', function(Builder $builder) {
            $builder->where('status', '=', 1);
        });

    }

And use laravel-scout-mysql-driver for search q=dfds

It occur QueryException
select count(*) as aggregate from `posts` where (`content` LIKE :_search0) and `posts`.`deleted_at` is null and `status` = %dfds%)

Not compatible with Scout 3

composer.json

    "laravel/scout": "^3.0",
    "damiantw/laravel-scout-mysql-driver": "^1.0"

Problem:
damiantw/laravel-scout-mysql-driver v1.0.7 requires laravel/scout ^2.0

Fulltext index on one column

How to make fulltext index on only one column? When I call php artisan scout:mysql-index it returns fulltext index from all text and varchar columns.

Appending an accessor throws an error

If in a model I use protected $appends to add say a computed field like full_address then you will get

Undefined offset: 0 {"exception":"[object] (ErrorException(code: 0): Undefined offset: 0 at .../vendor/yab/laravel-scout-mysql-driver/src/Services/ModelService.php:44)

Will submit a simple PR that will fix this now

Not compatible with Laravel 5.4

composer.json

"laravel/framework": "5.4.*",
"laravel/scout": "^3.0",
"damiantw/laravel-scout-mysql-driver": "^1.0"

Problem:
damiantw/laravel-scout-mysql-driver v1.0.7 requires laravel/framework 5.3.* and laravel/scout ^2.0

Missing ability to disable global scope when searching

When using global scopes, in my case based on user permission, and you want to disable those scopes for fetching, normally you can do something like:

$users = User::withoutGlobalScope(UserScope::class)->get();

When searching, it isn't possible to pass custom calls to the MySQL engine. A (very very very) ugly workaround is to overwrite the search method to disable scopes before passing the model to the engine:

public static function search(string $query, $callback = null): Collection
{
        // Temporary disable global scopes
        static::$globalScopes = [];
        $results = (new ScoutBuilder(new static(), $query, $callback))->get();
        static::addGlobalScope(new UserScope());
        return $results;
}

Any other ideas how to resolve this in a more elegant way?

Selected columns and some correction

I wanted to use this package so that I can use the benefit of Laravel Scout with MySql FULLTEXT. Instead of using raw full text query I used this package so that in future I can easily change the driver and if needed can use more efficient Search driver like elasticsearch, TNTSearch or algolia.
I found many issue while installing and implementing it. But in the end I was able to install it successfully. For someone who may need this-

First, DamianTW\MySQLScout\Providers\MySQLScoutServiceProvider::class, did not work for me it was showing error on running command. So I changes it to
Yab\MySQLScout\Providers\MySQLScoutServiceProvider::class,
The command php artisan scout:mysql-index App\\Post didn't work for me. I changed it to
php artisan scout:mysql-index App\Post . May be I am using windows ?

Now to allow only few selected table columns you should override toSearchableArray() method in your model before running above command.

public function toSearchableArray()
{
     
    // Customize array...
    return [
        'title' => $this->title,
        'body' => $this->body,
    ];
}

Make sure your column is of type text or varchar
To name the index name override searchableAs() method in your model before running above command

public function searchableAs()
{
     return 'search_index';
}

Note if you already have FULLTEXT defined in your table then you can match the above value in searchableAs() and toSearchableArray() methods by providing exact same values.

Hope this help someone.
Let me know if it can be improved further or I need to make any correction

Appends array is searched for in columns

Currently when you use the protected $appends array on your model the plugin searches for these names in your database as well resulting in Column not found: 1054

Search part of word

hi.
I want to search some part of text. for example in the "applegood" I want to search "ppleg" return result.
but in NATURAL_LANGUAGE mode it returns no result; so in BOOLEAN mode i use * ppleg * and no result returned. but in "apple*" results returned.
so can i have search like this in NATURAL_LANGUAGE? and if not how can use "*" operator in first of query?

Relevance as an attribute in model

I am searching in few models, for example in tables 'posts' and 'categories'. In each separately relevance works good, but I get 2 collections, so order of rows depends on what collection I view first. Is there a way to get relevance attribute to sort merged collections by it?

General problem when searching

I have a general problem when searching with this package. For example when I search for Barbara - when the search term is Ba, the Barbara's are found, with Barb I get no results. Even with Barbara as the search term, nothing is found.

I'm running:

  • Laravel 5.3.31
  • scout 2.0.2
  • PHP 7.0.15
  • MariaDB 10.1.20

... and use the default config:

'mysql' => [
	    'mode' => 'NATURAL_LANGUAGE',
	    'model_directories' => [app_path() . '/Models'],
	    'min_search_length' => 0,
	    'min_fulltext_search_length' => 4,
	    'min_fulltext_search_fallback' => 'LIKE',
	    'query_expansion' => false
    ]

SQLSTATE[HY000]: General error: 1214

[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1214 The used table type doesn't support FULLTEXT indexes (SQL: CREATE FULLTEXT INDEX companies ON companies (title))

Anyone who can help with this?) I can't figure it out!

DB table prefix not handled correctly

In response to #8, the database prefix is added to the $tableName attribute of ModelService (58aae1e). However, this prefix should only be added when executing SQL queries, not when using Laravel Database Builder functions like getColumnListing() as the Builder automatically prefixes table names with the configurated db prefix.

Please support for Laravel 5.5

Hello,
Thanks for your great package. I installed it for laravel 5.4 and it worked fine, but when i tried to install in laravel 5.5, it won't installed.
please support for laravel 5.5

Search for all words

First things first... Great Package!

I'm using it to perform searches on a website that is hosted on a shared server. Impossible to install other services like elasticsearch for example.
My Model has a lot of text fields and relations to other models. I tried all search modes but didn't achieve the results I need.
If I search for multiple words, I need to get the results that match all those words in any of the searchable fields. Unfortunately It search for each word and return all the records that have at least on of these words.

Example:
1-
Title: Table vintage
Body: beautiful furniture

2-
Title: modern table
Body: modern design

3-
Title: beautiful chair
Body: vintage design

Searching for "beautiful table" it returns all the items. How to get only the first one that has both words.
Is that possible with fulltext search?

Thanks for your help!

What is the benefits of using this package?

hi .if this Laravel Scout driver does not need to update any indexes and no cache record , what is the benefits of using this package ?

is it faster than eloquent queries ???

thank you

Not compatible with Scout 2

Using version ^1.0 for damiantw/laravel-scout-mysql-driver
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- damiantw/laravel-scout-mysql-driver v1.0.4 requires laravel/scout ^1.1 -> satisfiable by laravel/scout[v1.1.10, v1.1.11, v1.1.12, v1.1.3, v1.1.4, v1.1.5, v1.1.6, v1.1.7, v1.1.8, v1.1.9] but these conflict with your requirements or minimum-stability.
- damiantw/laravel-scout-mysql-driver v1.0.3 requires laravel/scout ^1.1 -> satisfiable by laravel/scout[v1.1.10, v1.1.11, v1.1.12, v1.1.3, v1.1.4, v1.1.5, v1.1.6, v1.1.7, v1.1.8, v1.1.9] but these conflict with your requirements or minimum-stability.
- damiantw/laravel-scout-mysql-driver v1.0.2 requires laravel/scout ^1.1 -> satisfiable by laravel/scout[v1.1.10, v1.1.11, v1.1.12, v1.1.3, v1.1.4, v1.1.5, v1.1.6, v1.1.7, v1.1.8, v1.1.9] but these conflict with your requirements or minimum-stability.
- damiantw/laravel-scout-mysql-driver v1.0.1 requires laravel/scout ^1.1 -> satisfiable by laravel/scout[v1.1.10, v1.1.11, v1.1.12, v1.1.3, v1.1.4, v1.1.5, v1.1.6, v1.1.7, v1.1.8, v1.1.9] but these conflict with your requirements or minimum-stability.
- damiantw/laravel-scout-mysql-driver v1.0.0 requires laravel/scout ^1.1 -> satisfiable by laravel/scout[v1.1.10, v1.1.11, v1.1.12, v1.1.3, v1.1.4, v1.1.5, v1.1.6, v1.1.7, v1.1.8, v1.1.9] but these conflict with your requirements or minimum-stability.
- Installation request for damiantw/laravel-scout-mysql-driver ^1.0 -> satisfiable by damiantw/laravel-scout-mysql-driver[v1.0.0, v1.0.1, v1.0.2, v1.0.3, v1.0.4].

Installation failed, reverting ./composer.json to its original content.

Where null issue

Laravel: 5.5.18

Hi I was testing this package and see some strange behavoir with nullable columns.
I have this query:

Invoice::search('fox')
            ->where('exported', null)
            ->get();

This generates a query like this:

select * from `invoice` where exported = '' AND (`name` LIKE '%fox%')

What I expect:

select * from `invoice` where exported = null AND (`name` LIKE '%fox%')

This is incorrect... Also adding a extra parameter to the where is incorrect:

Invoice::search('fox')
            ->where('exported', '!=', null)
            ->get();
select * from `invoice` where exported = '!=' AND (`name` LIKE '%fox%')

What I expect:

select * from `invoice` where exported != null AND (`name` LIKE '%fox%')

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.