I want to have a search engine for my website, is any of these web search engines(like Google,yahoo,etc) provide a free service? Or I should do it by myself
Aside from writing the Database queries and filters yourself, you could try out the Google Custom Search.
Zend_Search_Lucene is a fully implemented and fast PHP based fulltext search engine. You'll have to index your own data but it provides a great deal of flexibility and control (search content, type, associated data to return etc). There are also implementations in many other languages.
This is a better option if you are indexing products or documents, not if you want the content of your website to be searched à la Google.
Well I think it would be important to describe what exactly you're trying to "search" for. Is your site inventory based? Or is it just pages of information that you share?
If your site is inventory that you show, then it's entirely possible to create a database query to search for items off your site.
However, if your site is just pages of information with no database connectivity, then you may find it harder to write one yourself and thus should use a third party search such as google.
You could use google's api/ajax service for your site. I'd submit a sitemap.xml, and a robots.txt file for search engines to crawl your site.
You have to pay for Google Custom Search (CSE) unless you are OK with showing ads for other services on your site. You can accomplish something similar to CSE with a lot more flexibility by implementing Google's Search API.
Check out their example implementations, specifically the one about a simple search box.
I have always done my own, If like me your website makes use of an SQL based database, WHERE and %LIKE% for me seem to provide all the functionality required.
If you use MySQL, there is nothing easier. Use MySQL Full-Text Search functions: http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html
You can even short results according to relevance. Google it, examples are everywhere.