Skip to content

Full-text searching is performed using MATCH() AGAINST() syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a string value that is constant during query evaluation.

Notifications You must be signed in to change notification settings

ibnudirsan/FullText-search-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FullText Search MySQL

Full-text searching is performed using MATCH() AGAINST() syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a string value that is constant during query evaluation.

<?php

namespace App\Model\articlesBlog;

use Ibnudirsan\FullText\App\Helper\Searchable;

/*
|--------------------------------------------------------------------------
| Rumah Dev
| Backend Developer : ibudirsan
| Email             : [email protected]
| Copyright © RumahDev 2022
|--------------------------------------------------------------------------
*/

class articlesBlog extends Model
{
   /**
    * Add Searchable at Model
    */
    use Searchable;

   /**
    * Add property $searchable
    */
    protected $searchable = [
        'articleContent'
    ];
}
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Ibnudirsan\FullText\App\Helper\Searchable;

/*
|--------------------------------------------------------------------------
| Rumah Dev
| Backend Developer : ibudirsan
| Email             : [email protected]
| Copyright © RumahDev 2022
|--------------------------------------------------------------------------
*/

class PostBlogsController extends Controller
{
    use Searchable;
    
    public function search($search) {
        $result = articlesBlog::select('id', 'TitleArticle', 'slugArticle', 'Excerpt', 'articleContent')
                                ->search($search)
                                ->get();            
        return $result;
    }
}

About

Full-text searching is performed using MATCH() AGAINST() syntax. MATCH() takes a comma-separated list that names the columns to be searched. AGAINST takes a string to search for, and an optional modifier that indicates what type of search to perform. The search string must be a string value that is constant during query evaluation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages