How can I make a full text index of the column?


Here is my current migration:

class News extends Migration
    public function up()
        Schema::create('News', function (Blueprint $table) {

    public function down()

Now I need to make a full text index on these columns separately: title description. So I’m looking for something like this: ->fulltext(). But I don’t find anything similar in the Laravel documentation.


  1. how can I make a full text index on a single column in migration? Like: (title)
  2. Also for my information, how can I make a composite full text index on multiple columns in migration? Like: (title, description)

Note: I want an intex that lets me search like this: . . . match(col) against('value')


Laravel doesn’t support FULLTEXT search.
But you can use raw queries as:

DB::statement('ALTER TABLE News ADD FULLTEXT search(title, description)');

Note – that if you are not using MySQL 5.6+ we must set the Database Engine to MyISAM instead of InnoDB.

$table->engine = 'MyISAM'; // means you can't use foreign key constraints

For searching, you can do as:

$q = Input::get('query');

->whereRaw("MATCH(title,description) AGAINST(? IN BOOLEAN MODE)", array($q))

Answered By – Amit Gupta

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published