This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » Search plugins » sf lucene not showing results
sf lucene not showing results [message #95363] Fri, 12 March 2010 16:07 Go to next message
vishant  is currently offline vishant
Messages: 14
Registered: January 2010
Location: suriname
Junior Member
Hi everyone,

I configured the plugin manually but it's not returning any results.
My search terms are saved in the database.

These are the steps:

1. i inserted the zend search library in the vendor folder
2. i made the schema
3. i made a route
4. i created a search module (frontend)
5. i made a search form:
<div class="component search" id="search_container_side">
    <form action="<?php echo url_for('search'); ?>"  method="post">
            <input name="search[query]" type="text" />
            <button type="submit">
                <span>Zoek</span><!--[if IE]>&nbsp;&nbsp;&nbsp;&nbsp;<![endif]-->

6. this is my action:
public function executeIndex(sfWebRequest $request)
        $this->form = new AdvancedSearchForm();

        if ($request->getParameter('search'))

                $this->query = strtolower($this->form->getValue('query'));

                print($this->query).'<br />';


                $query = '';
                $query .= $this->query;

                $this->hits = LuceneHelper::getLuceneIndex()->find($query);
                #$this->jobs = LuceneHelper::getLuceneIndex()->find($this->query);



7. i added : LuceneHelper class in the lib folder;


class LuceneHelper
     * Return an array of Documents that match the given query
    static public function search($query)
        $hits = array();

        if ($query) {
            $hits  = self::getLuceneIndex()->find($query);

        return $hits;

     * Returns the Lucene Index
    static public function getLuceneIndex()

        if (file_exists($index = self::getLuceneIndexFile())) {
            return Zend_Search_Lucene::open($index);
        } else {
            return Zend_Search_Lucene::create($index);

     * Clears the index
    static public function clearLuceneIndex()
        if (file_exists($index = self::getLuceneIndexFile()))

     * Convenience method to generate the index path
    static public function getLuceneIndexFile()
        return sfConfig::get('sf_data_dir') . '/lucene.' . sfConfig::get('sf_environment') . '.index';

8. I edited the NewsPeer:
 static public function reIndexLucene($fresh = false)


        $index = LuceneHelper::getLuceneIndex();

        $crit = new Criteria();
        $crit->add(NewsPeer::ACTIVE, 1);
        $abouts = NewsPeer::doSelectJoinAll($crit);

        foreach($abouts as $obj)
            $doc = new Zend_Search_Lucene_Document();

            $doc->addField(Zend_Search_Lucene_Field::UnIndexed('pk', $obj->getId()));

            $doc->addField(Zend_Search_Lucene_Field::UnStored('title', $obj->getTitle(), 'utf-8'));
            $doc->addField(Zend_Search_Lucene_Field::UnStored('titleSlug', $obj->getTitleSlug(), 'utf-8'));
            //$doc->addField(Zend_Search_Lucene_Field::Text('catId', $obj->getCatId()));
            $doc->addField(Zend_Search_Lucene_Field::UnStored('intro', $obj->getIntro(), 'utf-8'));
            $doc->addField(Zend_Search_Lucene_Field::UnStored('body', $obj->getBody(), 'utf-8'));

            //$doc->addField(Zend_Search_Lucene_Field::unIndexed('route', 'about_detail', 'utf-8'));
            //$doc->addField(Zend_Search_Lucene_Field::UnStored('searchTags', $obj->getTags(), 'utf-8'));



        return $index;

Can anyone help me?
I added content in my db.
My search doesn't show any results.

Thanx in advance everyone.

[Updated on: Fri, 12 March 2010 16:11]

Re: sf lucene not showing results [message #101798 is a reply to message #95363 ] Wed, 30 June 2010 02:15 Go to previous messageGo to next message
ricardojguzman  is currently offline ricardojguzman
Messages: 26
Registered: March 2010
Junior Member
Hello vishant.

I'm in the same situation as you are. The only difference is that I followed the jobeet way. Lucene is not returning anything.

I tried changing the partial file and still nothing Confused

Seems like I did the same steps as you.

[Updated on: Wed, 30 June 2010 02:17]

Re: sf lucene not showing results [message #101842 is a reply to message #95363 ] Wed, 30 June 2010 14:51 Go to previous message
ricardojguzman  is currently offline ricardojguzman
Messages: 26
Registered: March 2010
Junior Member
My old reply only appears when I press the reply button but not on the thread..

I had the same problem but solved it. Can you post your partial file? My problem was there. I found the solution via this post, had to translate it: rameworks/symfony/jointure-relation-1-n/
This is my _luceneList partial

 <?php foreach ($personas as $personass): ?>
      <td><a href="<?php echo url_for('admins/edit?usuarioid='.$personass->getUsuarioid()) ?>"><?php echo $personass->getUsuarioid() ?></a></td>
      <td><?php echo $personass->getCedula() ?></td>
      <td><?php echo $personass->getNombres() ?></td>

>_< nvm now I see it in the thread. Sorry for the double post!.

[Updated on: Wed, 30 June 2010 14:52]

Previous Topic:[solved] sfLucenePlugin status ? is it alive ?
Next Topic:autocomplete plugin -not working for me..
Goto Forum:

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software