The simplest way would be to try something like this:
var mySearch = new google.search.WebSearch;
mySearch.setSiteRestriction('http://www.colonie.org/library/digitalLibrary/materials');
searchControl.addSearcher(mySearch);
That said, you will very likely find that a searcher set up this way will not
return the results you expect. The API does not handle being restricted to a
given domain or url all that well. Fortunately, though, there is a workaround.
I would suggest setting up a custom search engine which is restricted to your
site, and then replacing the url in the .setSiteRestriction call above with the
CSE's id.
Jeremy R. Geerdes
Effective website design & development
Des Moines, IA
For more information or a project quote:
http://jgeerdes.home.mchsi.com
[email protected]
If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
On Jul 27, 2010, at 3:31 AM, Paul wrote:
> 1. The .execute came with the "Google" argument below. If I am only
> interested in searching my domain (http://www.colonie.org/library/
> digitalLibrary/materials), is this valid or do I need something else?
>
> searchControl.execute("Google");
>
>
> 2. The only search options it came with are those listed below, none
> of which is searching my own domain where I only want it to search:
> http://www.colonie.org/library/digitalLibrary/materials). How do I add
> a searcher that only searches my domain?
>
> Paul
>
>
> // Add in a full set of searchers
> var localSearch = new google.search.LocalSearch();
> searchControl.addSearcher(localSearch);
> searchControl.addSearcher(new google.search.WebSearch());
> searchControl.addSearcher(new google.search.VideoSearch());
> searchControl.addSearcher(new google.search.BlogSearch());
>
>
>
>
>
>
>
> On Jul 26, 8:36 pm, Jeremy Geerdes <[email protected]> wrote:
>> .execute expects a query argument. Also, LocalSearch is not the same as a
>> web search of a directory on your domain.
>>
>> Jeremy R. Geerdes
>> Effective website design & development
>> Des Moines, IA
>>
>> For more information or a project quote:http://jgeerdes.home.mchsi.com
>> [email protected]
>>
>> If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan
>> Church!
>>
>> On Jul 26, 2010, at 6:17 PM, Paul wrote:
>>
>>> Hi
>>> I just set up a Google search for directory on a domain. I received
>>> the key and implemented the search. However, when I search, nothing
>>> happens. Is there something else I need to do?
>>
>>> Below is the key/function I am using. It is limited to just seaching
>>> my site. Does anyone have any ideas?
>>
>>> Paul
>>
>>> <script src="http://www.google.com/jsapi?
>>> key=ABQIAAAAKkdcQnG5ibIH5TrJS1pzsBS7Vib274SNYtfYKyMnP9kJl-
>>> AGexSQtjf09HWmXPROgHUDvFKRtkCIfQ" type="text/javascript"></script>
>>> <script language="Javascript" type="text/javascript">
>>> //<![CDATA[
>>
>>> google.load("search", "1");
>>
>>> function OnLoad() {
>>> // Create a search control
>>> var searchControl = new google.search.SearchControl();
>>
>>> // Add in a full set of searchers
>>> var localSearch = new google.search.LocalSearch();
>>> // searchControl.addSearcher(localSearch);
>>
>>> // Set the Local Search center point
>>> localSearch.setCenterPoint("Albany, NY");
>>
>>> // Tell the searcher to draw itself and tell it where to attach
>>> searchControl.draw(document.getElementById("searchcontrol"));
>>
>>> // Execute an inital search
>>> searchControl.execute();
>>> }
>>> google.setOnLoadCallback(OnLoad);
>>
>>> //]]>
>>> </script>
>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google AJAX APIs" group.
>>> To post to this group, send email to
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group
>>> athttp://groups.google.com/group/google-ajax-search-api?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google AJAX APIs" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-ajax-search-api?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en.