![]() |
|
sfPropelZSLSearchPlugin - 0.0.3sfPropelZSLSearchPlugin integrates symfony, Propel, and Zend Search Lucene together to instantly add a search engine to your application. |
|
Some of the plugins offer one-click modules to easily add complete features to your symfony applications
This plugin still needs to be claimed by its lead developer.
If you are the lead developer of this plugin, please send an email to fabien.potencier [[at]] symfony-project.com with your username.
![]() |
DescriptionsfPropelZSLSearchPlugin integrates symfony, Propel, and Zend Search Lucene together to instantly add a search engine to your application. |
| Name | |
|---|---|
|
|
ten.tfoslrac <<ta>> vlrac |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.3alpha | MIT license | 0.0.3alpha | 02/09/2007 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 27/08/2007 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 22/08/2007 |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.3alpha | MIT license | 0.0.3alpha | 02/09/2007 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 27/08/2007 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 22/08/2007 |
| Version | License | API | Released |
|---|---|---|---|
| 0.0.3alpha | MIT license | 0.0.3alpha | 02/09/2007 |
| 0.0.2alpha | MIT license | 0.0.2alpha | 27/08/2007 |
| 0.0.1alpha | MIT license | 0.0.1alpha | 22/08/2007 |
| Name | Channel | Version |
|---|---|---|
| sfPropelZSLSearchPlugin | pear.symfony-project.com | 0.0.1-1.0.0 |
--------------------------------------------------------------------------------
sfPropelZSLSearchPlugin
--------------------------------------------------------------------------------
Copyright (c) 2007 Carl Vondrick
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
Zend Search Lucene
--------------------------------------------------------------------------------
Copyright (c) 2005-2007, Zend Technologies USA, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of Zend Technologies USA, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
We first need to find the lead developer of this plugin before you can contribute to it.
If you are the lead developer of this plugin, please send an email to fabien.potencier [[at]] symfony-project.com with your username.
php symfony plugin:install sfPropelZSLSearchPlugin --release=0.0.3
php symfony plugin:install sfPropelZSLSearchPlugin --release=0.0.3
php symfony plugin-install http://plugins.symfony-project.org/sfPropelZSLSearchPlugin
sfPropelZSLSearchPlugin integrates symfony, Propel, and Zend Search Lucene together to instantly add a search engine to your application. Documents are either created off Propel models or HTML output from actions. The plugin ships with a fully functional search interface that you can easily add to your application. The goal of this plugin is to be a flexible search engine that can integrate with other plugins, such as sfSimpleCMSPlugin or sfSimpleBlogPlugin.
This plugin is still a alpha release. Use at your own risk! I encourage you to use it, but if you wake up and find your hard drive deleted, then you know why. A beta will not come until after symfony 1.1 ships. This documentation is still much a work in progress. It assumes that you have knowledge of symfony, Propel, and basic plugin tasks. If you find a bug or have a feature suggestion, please let me know!
Install the plugin:
$ symfony plugin-install http://plugins.symfony-project.com/sfPropelZSLSearchPlugin
Initialize configuration files (Don't do this if you are upgrading):
$ symfony pzsl-init myapp
Clear the cache:
$ symfony cc
Configure the search engine per the instructions below
There are currently two supported ways to add documents to the search engine:
Whenever possible, it is recommended to use the first option. The action output is often error-prone.
The entire search engine is configured by search.yml files, located in your project's config directory, your applications' config directories, and your modules' config directories, which is where you set up the various indexing options.
Setting up the plugin to index your models is easy. First, you must define the models you want to index in your project's search.yml file. The example below shows a search.yml for a blog:
models:
BlogPost:
fields:
title:
boost: 1.5
type: text
content: unstored
author: unindexed
friendlytitle: text
description: shortdescription
title: friendlytitle
description: shortdescription
BlogComment:
fields:
title: keyword
content: unstored
title: title
index:
name: MyIndex
encoding: UTF-8
cultures: [fr_FR](en_US,)
See the Zend_Search_Lucene documentation for more about the field types.
Next, you need to tell the engine where to send the user should the model be returned. You do this by creating your application's config/search.yml and defining a route for the model:
models:
BlogPost:
route: blog/showPost?slug={$slug}
BlogComment:
route: blog/showComment?id={$id}
In routes, {$xxxx} is a token and will be replaced by the appropriate field value. So, {$slug} will be the value returned by ->getSlug() on the model.
Finally, you must register the models with the plugin so that they will automatically update the index. You can do this by opening up the model's file and putting
sfPZSLBehavior::getInitializer()->setupModel('MyModel');
after the class declaration. So, for a blog, you would open project/lib/model/BlogPost.php and append the above, replacing "!MyModel" with "!BlogPost". (Note: this is the same thing as a Propel behavior.)
You're now set. If you want to index your already existing data, simply run
$ symfony pzsl-rebuild myappp
on the command line, replacing "myapp" with your application.
Note: This is not recommended for dynamic data because the actions are only updated when you rebuild the index. Also, currently, it is not possible to index more than one application (if anyone has a nice way of doing this, let me know).
To setup an action to be indexed, you must create a file in the module's config directory named search.yml. Inside this file, you define the actions you want indexed:
privacy:
tos:
security:
authenticated: true
credentials: [admin]
disclaimer:
params:
advanced: true
layout: true
As you can see, it is possible to define request parameters, manipulate authentication, and toggle decorating the response. By default, the response is not decorated, the user is not authenticated without any credentials, and there aren't any request parameters.
After you have saved this file, you can rebuild the index by:
$ symfony pzsl-rebuild myapp
The system ships with a very basic search interface that you can use as a search engine on your public application. To enable the engine, open the application's settings.yml file and in the enabled_modules section, add 'sfPropelZSLSearch'. It will look like:
all:
.settings:
enabled_modules: [sfPropelZSLSearch](default,)
You can now access the search engine in your project: http://localhost/myproject/web/sfPropelZSLSearch. You can define your own routes in the routing.yml file.
If you want to add a search box to your navigation for instance, simply make a call to the following component:
You can customize the search results by overriding various templates and actions to tailor the look and feel to your application. To do this, first create the folder yourapp/modules/sfPropelZSLSearch. To override the templates, then create a templates directory: yourapp/modules/sfPropelZSLSearch/templates. To see the templates that you can override, browse to the files in plugins/sfPropelZSLSearchPlugin/modules/sfPropelZSLSearch/templates.
Often, when writing a search engine, you need to display a different result template for each model. For instance, a blog post should show differently than a forum post. You can easily customize your results by changing the "partial" value in your application's search.yml file. For example:
models:
BlogPost:
route: blog/showPost?slug={$slug}
partial: blog/searchResult
ForumPost:
route: forum/showThread?id={$id}
partial: forum/searchResult
The partial that you specify is given a $result object that you can use to build that result. The API for this object is pretty simple:
$result->getInternalTitle() returns the title of the search result.$result->getInternalRoute() returns the route to the search result.$result->getScore() returns the score / ranking of the search result.$result->getXXX() returns the XXX field.In addition to the $result object, it is also given a $query string, which was what the user searched for. This is useful for highlighting the results.
The plugin has an optional highlighter than will attempt to highlight keywords from searches. The highlighter will hook into this search engine and also attempts to hook into external search engines, such as Google and Yahoo!.
To enable this feature, open the application's config/filters.yml file and add the highlight filter before the cache filter:
rendering: ~
web_debug: ~
security: ~
# generally, you will want to insert your own filters here
highlight:
class: sfPZSLHighlightFilter
cache: ~
common: ~
flash: ~
execution: ~
By default, the highlighter will also attempt to display a notice to the user that automatic highlighting occured. The filter will search the result document for <!--[HIGHLIGHTER_NOTICE]--> and replace it with an i18n-ready notice (note: this is case sensitive).
To highlight a keyword, it must meet the following criteria: * must be X/HTML response content type * response must not be headers only * must not be an ajax request * be inside the
tag * be outside of
