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
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.
Maybe Google Custom Search?
Check out Google Custom Search Engine.
Aside from writing the Database queries and filters yourself, you could try out the Google Custom Search.
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.
How about Sphinx?
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.
You can build small search engine with Pedatus - Micro Search Engine and Orinus - JavaScript SandBox
This is example site: Paesia - Micro Search Engine
You can use a YaCy installation using the Portal Mode:
This is really easy and there are lots of monitoring and SEO tools included as well.
Google provides custom search at free of cost upto 100 queries per day. If you want more you have to pay. Google search for website