Archives For console

I’ve spent the past couple of weeks developing a search engine for a Yii-based site (my problems and solutions specific to the search engine will be addressed in a separate post). As you may know, a search engine is really two things:

  1. One tool for creating the site index
  2. Another tool for searching the index and displaying the results

For both, I used the Zend_Search_Lucene module within Yii (or, I think that’s the route I’ll end up using). And although I initially created a Controller method for generating the index (per the instructions I sketched out in this other post), indexing a lot of content through a Web request is less than ideal. This particular site probably only has a hundred or more database records and a couple dozen files (PDFs) to be indexed, but the process still took a minute or two. Even if the index is only created or updated once a day or once a week, that’s still a lot of Web server resources being tied up. A better solution is to use a command-line script to create the index. Since most of the indexing requires a database connection and some Model information, I didn’t want to separate the indexing script from the Yii-based site. Fortunately, Yii supports command-line scripts by creating a “console application”. As with other things in Yii that are less common, the documentation on console applications is meager, but it was enough for me to go on. Here’s what you need to know… Continue Reading…