Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
lucene behavior for propel 15
PHP
tree: fbc218dc0b

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
config
lib
vendor/Zend
LICENSE
README.md

README.md

sfPropelLuceneableBehaviorPlugin

The sfPropelLuceneableBehaviorPlugin is a symfony plugin that enabled the model(s) to be searchable. This plugin use sfPropel15Plugin as an ORM.

Installation

  • Install the plugin

    git clone git://github.com/nibsirahsieu/sfPropelLuceneableBehaviorPlugin.git
    
  • Activate the plugin in the config/ProjectConfiguration.class.php

    [php]
    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function setup()
      {
        ...
        $this->enablePlugins('sfPropelLuceneableBehaviorPlugin');
        ...
      }
    }
    

How to use

  • Example:

    [xml]
    <table name="section">
      <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
      <column name="title" type="VARCHAR" required="true" primaryString="true" />
      <column name="content" type="LONGVARCHAR" required="true" />
      <behavior name="luceneable" />
    </table>
    

    if you don't supply the parameter values, the behavior will index all columns using UnStored method except the primary key (primary key will be indexed Using Keyword method).

  • Customizing behavior (format parameter value => fieldMethod:boost, ex: text:1.8)

    [xml]
    <table name="section">
      <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
      <column name="title" type="VARCHAR" required="true" primaryString="true" />
      <column name="content" type="LONGVARCHAR" required="true" />
      <behavior name="luceneable" >
        <parameter name='id' value='keyword' />
        <parameter name='title' value='text:1.5' />
        <parameter name='content' value='unstored:1.5' />
        <parameter name='published_at' value='unindexed' />
      </behavior>
    </table>
    

How to Search

  • pagination

    $pager = sfLuceneModelSearch::create($model, $query)->paginate($page=1, $limit = 10);
    
    [php]
    foreach ($pager->getResults() as $value)
    {
      echo $value->getTitle() . ',' . $value->getContent();
    }
    
  • non pagination

    $values = sfLuceneModelSearch::create($model, $query)->find($limit = 10);
    
    [php]
    foreach ($values as $value)
    {
      echo $value->getTitle() . ',' . $value->getContent();
    }
    

Available tasks

  * php symfony propel:lucene-create-index
  * php symfony propel:lucene-optimize-index
Something went wrong with that request. Please try again.