Source

php-libs / doctrine_lucene /

Filename Size Date modified Message
..
Lucene/branches/1.2-1.0
1.5 KB
Doctrine template for Zend_Search_Lucene
========================================

- [Zend_Search_Lucene documentation](http://framework.zend.com/manual/en/zend.search.lucene.html).

Usage
=====

Define your models:

    <?php
    class Article extends Doctrine_Record
    {
        public function setTableDefinition()
        {
            $this->hasColumn('id', 'integer', null, array('primary' => true,
                    'autoincrement' => true));
            $this->hasColumn('name', 'string', 128);
            $this->hasColumn('details', 'string');

            $this->actAs(new DoctrineX_Template_Lucene(array(
                'indexes_dir' => 'application/data/indexes',
                'fields' => array(
                    array('name' => 'name', 'type' => 'text', 'boost' => 5.0),
                    array('name' => 'details', 'type' => 'unStored'),
                ),
                'encoding' => 'UTF-8',
                'analyzer' => new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive(),
                'stopWords' => array('и', 'в', 'по'),
            )));
        }
    }

Use it:

    <?php
    class Article extends Doctrine_Record
    {
        public function search($q)
        {
            $hits = $this->getLuceneIndex()->find($q);
            return new Zend_Paginator(new Zend_Paginator_Adapter_Array($hits));
        }
    }

## Source code

Source code: [Doctrine_Template_Lucene](http://bitbucket.org/vladimir_webdev/doctrine_lucene/src/).