Search in multiple models(free search, not related, just like Yii website's search)

Hi, everyone,

I am making a search function in my website.

I know that each model has a search function so I can search within this model or in the relative model easily,

However, has anyone tried to search FREELY? So I can make a search function like goole’s site-search or the search in this website(you can search extension, forum, whatever).

Is there a way to build a search class to search all pages in the website(all models)?

Any hints about this site-search/free search/or some tricky/hacky way to acheive the search like the one on Yii’s website?

Thanks!!!!!!

You mean something like this?

That’s great! thanks!

Just one question…

In the post http://www.yiiframework.com/wiki/248/adding-search-to-yii-blog-example-using-zend-lucene

How could he access each page’s url?? Should I save each page’s url in the database…???? i don’t think that is a good idea…

I tried his code and it always give me


Field name "link" not found in document.

Any ideas…?

It will be useless if i can’t get each page’s url…

Jiaming,

No…no, not the database.

Just as you do not store each post url in the database, however the post url is still accessible. The same principle applies here.

<br class="Apple-interchange-newline">So, judging from


$post->url 

This basically means that you may define a public property in your model class. Then some method to Yii::app()->createUrl()

to access your site.

I do not think the author wrote it as a copy paste code.

In fact, the yii blog will make the point clearer.

The author did say based on yii blog. He’s writing style also leaves the reader with homework exercise.

That is very helpful. Thank you!