Searching
You should already have a Searchable
model and a Search Engine configured. If it is not the case, please read the Getting Started guide.
Basic Search
You can begin searching a model using the search
method. It accepts a single string as a search query.
Raw results
Magnify automatically map the results from the Search Engine with your Lucid Model by querying the database.
Sometimes you might want to get the raw results from your Search Engine. You can do that by using the raw
method.
Custom Index
When searching a model it will use the searchableAs
method to determine the index name. If you want to search a different index, you can use the within
method.
Filtering
You can filter the results using the where
, whereIn
and whereNotIn
methods.
It is possible to chain filters
Sorting
Sorting is done using the orderBy
method. It accepts a field name and a direction. The direction can be either asc
or desc
.
It can be chained to refine the results order.
Pagination
Pagination is done using the paginate
method. It accepts a page number and a per page limit.
It returns a SimplePaginator
: