Download the PHP package best-served-cold/laravel-zendsearch without Composer
On this page you can find all versions of the php package best-served-cold/laravel-zendsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download best-served-cold/laravel-zendsearch
More information about best-served-cold/laravel-zendsearch
Files in best-served-cold/laravel-zendsearch
Package laravel-zendsearch
Short Description ZendSearch implementation for Laravel - Local file based search engine
License MIT
Informations about the package laravel-zendsearch
LaravelZendSearch
A fast implementation of ZendSearch hooking into Laravel eloquent. Utilise the power of Lucene without installing a secondary service such as Elasticsearch or Solr.
After using a couple of packages for ZendSearch in Laravel I was disappointed with the performance, so I created my own.
Installation
Follow these steps to get the package in place:
Setup
Update composer and then add the ServiceProvider
to config/app.php
:
I'm not keen on Facades, but if you want to use one, add it to the aliases in config/app.php
:
Publish
Get your config published:
Usage
Indexing
Add the and use it in the models you want to use:
Then add the method and populate it with the fields you want to be indexed:
If you want to "boost" fields, then add the following method:
The index will build automatically from there.
Relations
If you want to index relations, make sure you create your method and then add the relation to the array in your model.
Building
If you have existing data or have changed your search fields, you can rebuild the index from scratch:
Destroy:
Optimise:
I'll work on a scheduler in the near future, but make sure you optimise your index regularly. I'd suggest scheduling it yourself for now every hour or so.
Searching
Basic
Create a search instance:
Deleting
Advanced
Filters
There are two basic filters implemented in the configuration which you can override, StopWords and ShortWords. You can, however, change both the filters and the analyzer manually to preset ZendSearch classes or custom classes:
Helpers
To assist in debugging, there are a few helpers which can assist:
Features to come
This is the first stable version which I've made mainly for my own use on another project. I will add the following in due course though.
- Scheduled optimisation out of the box
- Option passthrough added for Wildcard, Phrase, Fuzzy
- Add in highlighting options
All versions of laravel-zendsearch with dependencies
zendframework/zendsearch Version ^2.0@RC
illuminate/support Version ^5.3