Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ankitmlive's avatar

How to search with FULL TEXT INDEX in Laravel 5.5

Hi,Everyone i am making a Web-Application based on laravel. In this a huge table with 45 column is existed and also there are 3 million rows are inserted.I have to search data from table and show user when he searched from the homepage.How to apply full text search on this table. I have to search data with these column from 45 columns: 1-description (multiple keyword will be accepted) 2-hscode (number) 3-fromdate (date) 4-todate (date)

Note-Every month some new data will be uploaded on the table.Please give suggestions

0 likes
6 replies
ankitmlive's avatar

Hey Thanks man for reply. Can i use Laravel scout without Algolia ?

aurawindsurfing's avatar

No. Have read here:

Introduction

Laravel Scout provides a simple, driver based solution for adding full-text search to your Eloquent models. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records.

Currently, Scout ships with an Algolia driver; however, writing custom drivers is simple and you are free to extend Scout with your own search implementations.

ankitmlive's avatar

hmmm..i have done some r&d and find that ,i can use laravel scout with tntsearch which is also a full text search drive for scout.i am preferring tntsearch over algolia because i don't wants to upload my data to algolia server,i have sensitive data. Am i right ?

aurawindsurfing's avatar

Well you can modify what you send over to algolia, actually you have to do that for search to work better on dates for instance you do it in your model like so:

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

        // change date to bool, otherwise algolia will not allow us to filter those records out

        if (array_has($array, 'deleted_at')) {
            $array['deleted_at'] = $array['deleted_at'] == null ? 0 : 1;
        } else {
            array_set($array, 'deleted_at', 0);
        }

        if (array_has($array, 'order_by')) {
            $array['order_by'] = strtotime($array['order_by']);
        }

        unset(
            $array['email'],
            $array['agree']
        );

        return $array;
    }

So instead of giving them everything you give them only what you need to perform search. It all depends on what rules and ranking will you use inside of algolia.

ankitmlive's avatar

i wants to perform search on a PRODUCT_DESCRIPTION column which have sensitive data.so i am bound to use tntsearch over algolia. can i consider tntsearch performance same as algolia ?

Please or to participate in this conversation.