Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Zend_Search_Lucene is bad with numbers

Posted on 2009-05-03
4
Medium Priority
?
521 Views
Last Modified: 2013-12-08
I have a small site I have built using Doctrine and the Zend Framework. the Lucene search within the Zend Framework works great for me, except when the search terms have numbers in them. It hits the max execution time every time. But if I search with just text, it returns immediately.

Any ideas on how I can extend the search to be as efficient with numbers as it is letters/words?
class Search {
 
    const INDEX_DIR = '../search/data/';
 
    private $_index;
 
    static public function createIndex() {
        Zend_Search_Lucene::create( realpath( self::INDEX_DIR ) );
    }
 
    public function __construct() {
        try {
            $dir = realpath( self::INDEX_DIR );
            $this->_index = Zend_Search_Lucene::open( $dir );
            $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive( );
            $analyzer->addFilter( new Search_PorterStemmerFilter( ) );
            Zend_Search_Lucene_Analysis_Analyzer::setDefault( $analyzer );
        } catch (Exception $e) {
            self::createIndex();
            $this->__construct();
        }
    }
 
    public function find( $query ) {
        return $this->_index->find( $query );
    }
}
////////////////////////////////
////////////////////////////////
class SearchController extends Zend_Controller_Action {
      $term = $this->_getParam('q');
      $this->view->assign( 'term', ucwords( strtolower( $term ) ) );      
      
      $searcher = new Search( );
      if ( !empty( $term ) ) {
         
         $searchTerm = new SearchTerm( );
         $searchTerm->query = $term;
         if(array_key_exists('HTTP_REFERER', $_SERVER)) {
            $searchTerm->referrer = $_SERVER['HTTP_REFERER'];
         }
         
         $term = str_ireplace(array('bar','club'), '', $term);
         $term = trim($term);
         //$term .= '~.5';
         
         Zend_Search_Lucene::setResultSetLimit( 15 );
         
         $results = $searcher->find( '*' . $term . '*' );
         
         $this->view->assign( 'results', $results );
         
      
      }
      
   }

Open in new window

0
Comment
Question by:hallikpapa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 24345609
How do numeric searches perform when you leave out the asterixes?
0
 

Author Comment

by:hallikpapa
ID: 24365874
It seems to work better, but I need some sort of wildcard operation in there. Any suggestions?
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 1500 total points
ID: 24365959
You mean adding wildcards for numbers, or is it ok to only use them for non-numeric terms?
0
 

Author Comment

by:hallikpapa
ID: 24460607
I am going to just upgrade to the newest version and see if this resolves the problem.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question