Closed bee-interactive closed 2 years ago
Same issue here, using a different syntax:
return Product::where('name', 'like', "%" . $query . "%")
->get()
->map(function (Product $product) {
return new SpotlightSearchResult(
$product->id,
$product->name,
'description',
[]
);
});
I have multiple products with Zown
in the name. Yet only one gets shown in Spotlight results.
Note that products can have dots in the name and infos like 175.3 x 29.2 x h. 46.4cm
.
Any idea why I would get less results than available ?
Spotlight also uses Fuse.js to do additional searching. Maybe this is causing the issue. If you pass additional data as synonyms, this should be resolved, I think:
return new SpotlightSearchResult(
$product->id,
$product->name,
$product->code,
['additional', 'values', 'that', 'fuse.js', 'will', 'search']
);
@PhiloNL Yess the solution worked!
``Hi!
I have a project that can search through a list of products. For better search result, I have connected my model with Laravel Scout and Algolia.
When I search within my controller with some specific keywords, I get 9 results.
But when I search within the spotlight component, I only get 1 result..
Here's my function in my spotlight component:
It doesn't seem wrong to me.. Am I missing something? Does the SpotlightSearchResult group some results?
Thank you in advance for your support