0

I am using A Search Bar Form which searches in a database of +-175.000 Models. I've installed Scout accordingly to the documentation and imported all the records using scout:import.

Now, I've setup a function in my Controller to do the search and return all Records, but the records are always empty, regardless for what I search.

web.php:

Route::post('/act/search', ['uses' => 'ActController@searchAct', 'as' =>'searchAct']);

ActController@searchAct:

public function searchAct(Request $request)
{
    $actes = Act::search($request->search)->paginate(100);
    return view('act')->with('actes', $actes);
}

The form:

<form class="navbar-form navbar-left" action="{{ route('searchAct') }}" method="post">
    {{ csrf_field() }}
    <div class="form-group">
        <input type="text" name="search" id="search" class="form-control" placeholder="Search">
    </div>
    <button type="submit" class="btn btn-default">Search</button>
</form>

As far as I see this should work but dd($actes) say that the collection is empty. I've included the use Searchable; Entrait in my Model. Scout index the records fine: All [App\Act] records have been imported.

Drag and Drop
  • 2,672
  • 3
  • 25
  • 37
xTheWolf
  • 1,756
  • 4
  • 18
  • 43
  • Thank you @Pierre Lebon. Btw, is there an easy way to remove trailing spaces on SO? – xTheWolf Feb 15 '17 at 09:38
  • I use N++ as Post editor. In N++, Ctrl+A > Edit Menu > Blank Operation > Trim Trailing Space. Bonus: Blank Operation > Tab to Space is the key to have good indented code. – Drag and Drop Feb 15 '17 at 09:50
  • Thanks. I found out that there is no index file created. I'm using Homestead. Theres no index file on my windows machine in the storage folder. – xTheWolf Feb 15 '17 at 10:13
  • Do you have a job-runner for background tasks? – jessecurry Feb 25 '19 at 18:18

1 Answers1

1

I had a similar issue a few days ago and as previously mentioned in one of the comment above, laravel-scout wasn't generating the index file but I couldn't figure out why. Maybe the folks that built the package intended it that way for performance reasons.

Anyway in my own case I ended up integrating TNTSearch available here (with an easy to understand documentation) to do the indexing for me.

user28864
  • 3,375
  • 1
  • 25
  • 19