Skip to content

Filter/Scope search results in frontend #5036

Answered by jelleroorda
naabster asked this question in Q&A
Discussion options

You must be logged in to vote

No I don't think this is possible without writing your own implementation. You can still use the Search Index to get the results yourself pretty easily with something like this:

(Taken from the Statamic\Http\Controllers\CP\SearchController)

Search::index()
            ->ensureExists()
            ->search($request->query('q'))
            ->get()
            ->filter(function ($item) {
                // Implement your own custom filtering here, for example based on publish_date
            })
            ->take(10)
            ->map(function ($item) {
                return $item->toAugmentedCollection([
                    'title', 'edit_url',
                    'collection', 'is_entry',…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jelleroorda
Comment options

@naabster
Comment options

Answer selected by naabster
Comment options

You must be logged in to vote
1 reply
@naabster
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants