meilisearch / meilisearch-laravel-scout

MeiliSearch integration for Laravel Scout
https://github.com/meilisearch/MeiliSearch
MIT License
465 stars 43 forks source link

[Question] Custom search with where() #99

Closed robsontenorio closed 3 years ago

robsontenorio commented 3 years ago

Hi,

I am trying to combine custom search with where().

But the ->where('type_id', 3) does not take effect

 $result = Page::search('War', function (Indexes $meilisearch, $query, $options) {
            $options = ['attributesToHighlight' => ['description']];
            return $meilisearch->search($query, $options);
        })->where('type_id', 3)->raw();

If i do a simple search it works as expected. But, for sure, i dont get hililght anymore.

 $result = Page::search('War')->where('type_id', 3)->raw();
curquiza commented 3 years ago

Hello @robsontenorio! What is the version of meilisearch-laravel-scout you are using? Can you check from 0.12.1 and later and tell us when you have this failure? Thanks a lot, it would be really helpful! https://github.com/meilisearch/meilisearch-laravel-scout/releases

robsontenorio commented 3 years ago

@curquiza

Just noticed i cant combine other methods like ->take() with custom search. Is that expected?

docker image: meilisearch:v0.18.1

composer: meilisearch-laravel-scout": "^0.12.4", "laravel/scout": "^8.6", "laravel/framework": "^8.12"

use Illuminate\Database\Eloquent\Model;
use Laravel\Scout\Searchable;

class Page extends Model
{
    use Searchable;

}
curquiza commented 3 years ago

I don't think this is expected (can you confirm @shokme?)

@robsontenorio, can you check if it works (or not) with previous versions, like the v0.12.1 for example? Thanks!

robsontenorio commented 3 years ago

@curquiza No lucky at 0.12.1 :( Same issue.

robsontenorio commented 3 years ago

I am sorry! Wrong array syntaxe ... My bad!

Wrong

            $options = ['attributesToHighlight' => ['description']];

Right

            $options['attributesToHighlight'] = ['description'];