I'm using laravel scout with tntsearch driver in a laravel 7 project. Scout is always returning an empty collection if I search by id(uuid). But I get search results as expected if I search with fields other than id.
Controller
public function index(Request $request)
{
$coverNotes = null;
if (request('search'))
{
$coverNotes = CoverNote::search(request('search'))->paginate(1); // it is always empty while searching with id, which is of 'uuid' type
}
else
{
$coverNotes = $this->coverNote->paginate(1);
}
return View::make('cover-notes.index', compact('coverNotes'));
}
Model
class CoverNote extends Model
{
use Searchable, UuidTrait;
public $asYouType = false;
public function toSearchableArray()
{
$array = $this->toArray();
return $array;
}
}
config/scout.php
'queue' => env('SCOUT_QUEUE', false), // I didn't set it on .env
'tntsearch' => [
'storage' => storage_path(), //place where the index files will be stored
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'fuzzy' => [
'prefix_length' => 2,
'max_expansions' => 50,
'distance' => 2
],
'asYouType' => false,
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
],
scout:status
---------------------- ------------------- ----------------- --------------- ------------ --------------------
Searchable Index Indexed Columns Index Records DB Records Records difference
---------------------- ------------------- ----------------- --------------- ------------ --------------------
AppModelsCoverNote cover_notes.index 1 1 Synchronized
---------------------- ------------------- ----------------- --------------- ------------ --------------------
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…