How is site specific search done?
Can someone please tell how site specific searches are done. For examp开发者_开发百科le, search in the stackoverflow.com
Thanks
The search here on Stackoverflow is, as I can recall, done using Lucene.
You build an index with details you want to search through and link these to the posts / other things you want the search to find.
More details here: http://en.wikipedia.org/wiki/Lucene
They have used the SQL server search algorithm but were not really satisfied with it, if I remember correctly.
Here is the blog post by Jeff: https://blog.stackoverflow.com/2008/11/sql-2008-full-text-search-problems/
Depending on what you want you can build your own implementation to search trough a database or use Google Custom Search on Google CSE
Google, Bing, and Yahoo it is done as:
c++ site:stackoverflow.com
Search Google for "site:stackoverflow.com [SEARCH STRING]". This will only return pages that are hosted through *.stackoverflow.com.
Or, like Rob said, if you're looking to setup your own custom in-site search bar, you can use Google CSE.
If you're interested in the nuts-and bolts of "how site-specific searches are done" (your words), then you can take heart in that it is very easy; the URLs' host names ("http://www.example.com/path/to/page" => "www.example.com") are matched against the domain being searched.
Something that will really mess this up, though is the existence of DNS aliases and duplicate entries.
精彩评论