algolia / scout-extended

Scout Extended: The Full Power of Algolia in Laravel
https://www.algolia.com/doc/framework-integration/laravel/getting-started/introduction-to-scout-extended/
MIT License
400 stars 87 forks source link

Retrieving facets and values #197

Closed jrseliga closed 5 years ago

jrseliga commented 5 years ago

Is it possible to retrieve the facets and available values when executing a search similar to how the Instant Search component libraries work?

Property::search('query')->get();

Looking over the documentation, it seemed like with could be useful. e.g.

Property::search('query')->with([
    'facets' => ['beds', 'baths'];
])->get();

This doesn't seem to return that information though, is this information available using with?

If not it might be useful if the Collection that comes back from ->get() included a metadata property that would hold this type of additional information about the result set returned from Algolia.

nunomaduro commented 5 years ago

You will need to use the method raw:

$results = Property::search('query')->with([
    'facets' => ['beds', 'baths'];
])->raw();

The $results variable will contain all the information you need.