views:

91

answers:

3

I am using Google Search API in a website to produce results from the website.(the site) the problem is, it is not producing results at all. If I change the site restriction to some other site(e.g. wikipedia.org or any other) it produces results.

It is not that the site is not listed - when I search for site:www.hinroengineering.com on the Google home page I get results.

Code is as follows:

google.load('search', '1');

function OnLoad() {
    // Create a search control
    var searchControl = new google.search.SearchControl();

    // web search, open
    options = new google.search.SearcherOptions();
    options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);

    // Add in a WebSearch
    var webSearch = new google.search.WebSearch();

    // Restrict our search to pages from the current site only
    webSearch.setSiteRestriction('http://www.hinroengineering.com');
    webSearch.setUserDefinedLabel(" Search results  ");

    // Add the searcher to the SearchControl
    searchControl.addSearcher(webSearch, options);

    // tell the searcher to draw itself and tell it where to attach
    searchControl.draw(document.getElementById("SeachContent"));
    searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

    // execute an inital search
    searchControl.execute(CurrentSearchTerm);
    //alert(webSearch.results.length);

}

google.setOnLoadCallback(OnLoad);
A: 

Have you tried dropping the HTTP part from setSiteRestriction? Google documentation appears to use the convention setSiteRestriction("domain.com") without any protocol:

http://code.google.com/apis/ajaxsearch/documentation/

Kristopher Ives
tried it...still no results..:(
ZX12R
am i missing something obvious..?
ZX12R
A: 

got tired of making it work...now shifted to this search tool...it's giving good results... but i would really like to know why it didn't work...

ZX12R
A: 

I have the same problem. This is really annoying. Using a popular site returns results, using my own site returns 0 even though going to google.com and passing 'site:mysite.com' returns results.

Chris Harrison