Download the PHP package alkhvalko/sphinxsearch-bundle without Composer
On this page you can find all versions of the php package alkhvalko/sphinxsearch-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alkhvalko/sphinxsearch-bundle
More information about alkhvalko/sphinxsearch-bundle
Files in alkhvalko/sphinxsearch-bundle
Package sphinxsearch-bundle
Short Description Sphinx search bundle for Symfony
License MIT
Homepage https://github.com/IAkumaI/SphinxsearchBundle
Informations about the package sphinxsearch-bundle
SphinxsearchBundle
With this bundle you can use Sphinx to search in your Symfony2 project.
Installation
Step 1: Download SphinxsearchBundle using composer
In your composer.json, add SphinxsearchBundle:
Now, you must update your vendors using this command :
Step 2: Add bundle in AppKernel.php
Step 3: Configure your config.yml
By default bundle does not need to be a configured, but has some options for you.
Full configuration :
Services
- @iakumai.sphinxsearch.search - base search engine to use Sphinx search.
Maybe you want to use another class in @iakumai.sphinxsearch.search service. To do this put a full class name to the parameter named %iakumai.sphinxsearch.search.class%.
- @iakumai.sphinxsearch.doctrine.bridge - bridge to dictrine datebase.
Maybe you want to use another class in @iakumai.sphinxsearch.doctrine.bridge service. To do this put a full class name to the parameter named %iakumai.sphinxsearch.doctrine.bridge.class%. It must implements a IAkumaI\SphinxsearchBundle\Doctrine\BridgeInterface
Exceptions
- EmptyIndexException - you will see this exception if try to search without indexes.
- NoSphinxAPIException - this exception throws if not SphinxAPI was found.
Highlight search results
You can highlight search words in templates by use sphinx_highlight filter.
For example:
In this example matches for "query word" in content variable will be highlighted for IndexName index. It use BuildExcerpts method for this.
Useful features
Sphinx search by date range
For example, search link looks like http://site.ru/search/?date-start=26.09.2013&date-end=27.09.2013
Examples
This code will use IndexName index to search for a query in q-get parameter:
You can use all methods, that provides by PHP SphinxAPI.
For example:
Now bundle can auto convert search results to entities if you will search for one index or define a index_name attribute in sphinx config. To to this, first configure index names, for example:
To convert multiple queries please add index_name attribute to your sphinx.conf file, for example:
Now you can execute searchEx() method:
$results_one now will contains something like this:
$results_two now will contains something like this:
Pagerfanta adapter
This bundle also includes special adapter for excellent Pagerfanta bundle