search not returning anything

12 views
Skip to first unread message

Paul

unread,
Jul 26, 2010, 7:17:58 PM7/26/10
to Google AJAX APIs
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>

Jeremy Geerdes

unread,
Jul 26, 2010, 8:36:34 PM7/26/10
to google-ajax...@googlegroups.com
.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
jrge...@gmail.com

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!

> --
> You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group.
> To post to this group, send email to google-ajax...@googlegroups.com.
> To unsubscribe from this group, send email to google-ajax-searc...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-ajax-search-api?hl=en.
>

Paul

unread,
Jul 27, 2010, 4:31:36 AM7/27/10
to Google AJAX APIs
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 <jrgeer...@gmail.com> 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
> jrgeer...@gmail.com

Jeremy Geerdes

unread,
Jul 27, 2010, 8:25:19 AM7/27/10
to google-ajax...@googlegroups.com
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

jrge...@gmail.com

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!

Paul

unread,
Jul 27, 2010, 8:46:56 AM7/27/10
to Google AJAX APIs
Thanks Jeremy.

1. When you say that using the below method (without a custom search
engine) doesn't return the expected results that well, what do you
mean?

2. How do you configure the Google to index the new directories/pages
I have added to the existing site? I have looked at the developer
guide, which references an Admin Console, but I am not sure what this
is referring to.

Paul



On Jul 27, 8:25 am, Jeremy Geerdes <jrgeer...@gmail.com> wrote:
> 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
> > For more options, visit this group athttp://groups.google.com/group/google-ajax-search-api?hl=en.- Hide quoted text -
>
> - Show quoted text -

Jeremy Geerdes

unread,
Jul 27, 2010, 9:14:01 AM7/27/10
to google-ajax...@googlegroups.com
1. The API has a tendency to drop significant numbers of results when using the setSiteRestriction method with a simple url. To the point that, while there may be 15 results displayed on a google.com search running a search with site: (the same search operator the setSiteRestriction method uses in this case), the API will return 0 or 1.

2. I don't know exactly what documentation you read, so it's impossible to know which admin console it's referring to. But if you set up a Custom Search Engine, you can use the CSE's admin console to restrict it to a given site. Additionally, you can use the Webmaster Tools admin console to set up sitemaps, indexing on demand, etc.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com

jrge...@gmail.com

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!

omr

unread,
Jul 27, 2010, 1:36:20 PM7/27/10
to Google AJAX APIs
As Jeremy has suggested, one way forward is to set up a Custom Search
Engine (CSE) with On-Demand Indexing.

For information about Custom Search Engines, see:

http://www.google.com/cse/docs/
http://code.google.com/apis/customsearch/docs/start.html
http://www.google.com/support/customsearch/
http://www.google.com/cse/docs/tos.html

For information about On-Demand Indexing, see:

http://www.google.com/support/customsearch/bin/answer.py?answer=115959
http://www.google.com/support/customsearch/bin/topic.py?topic=16792
http://www.google.com/support/customsearch/bin/answer.py?answer=115958

.

The following suggested procedure describes how I might initially
proceed if I were in your situation. Please note that these are only
suggestions, intended to help you get started quickly. (This is
nowhere near a complete discussion of the many options available for
Custom Search.) Please read the Custom Search documentation and
decide how you'd like to proceed.

(Disclaimers: The following suggestions are provided 'as-is' without
any warranty. I'm not liable for errors, omissions, or any
consequences of use. I'm not offering any additional support or
assistance. I'm not affiliated with Google.)

.

To create your Custom Search Engine, go to:

http://www.google.com/cse/manage/create

(You may be asked to sign-in again.)

In the "Name" box, enter e.g.: "William K. Sanford Town Library
Materials". In the "Description" box, enter the same, or a short
description. (Don't spend more than a minute writing this entry; it
won't be displayed on your web site.)

In the "Sites to search" box, enter (or copy-and-paste) exactly this:

*.colonie.org/library/digitalLibrary/materials/*

Confirm that you have read and agreed to the Custom Search Terms of
Service, and click "Next". (The next page offers styling options;
ignore them for now.) Again click "Next".

You will be given code to create a search box (using the "Custom
Search Element"), but in this case I'd like to suggest an alternative
implementation initially. We'll get your search box code in the next
step. Click this link to go to your "My Search Engines" page:

http://www.google.com/cse/manage/all

(Please bookmark that page.)
Your Custom Search Engine is listed there.
Click the "control panel" link.
Click the "Look and feel" link (in the left column).
Under "Choose a hosting option", click: "Google-hosted page".

Note: The "Google-hosted page" option implements a search box that
puts results on a separate page hosted by Google. IMO this may be the
easiest way to get started immediately (with no changes to your
current site design). Later you can investigate the other results-
hosting options, and other considerations for search box
implementation.

Click the "Save" button. Click the "Get Code" button to obtain search
box code that implements the results-hosting option you chose. Copy-
and-paste the search box code to a test page on your site.

Initially the CSE may not produce results (your pages have not yet
been indexed). Next you'll need to create and submit a Sitemap, and
request On-Demand Indexing.

.

For information about Sitemaps, see:

http://www.google.com/support/webmasters/bin/answer.py?answer=156184

In the simplest form a Sitemap can consist of a list of URLs in a text
file. For your immediate purposes that may be sufficient. (Later you
may want to investigate the advantages of the XML Sitemap protocol.)

There are various software tools available to help create Sitemaps.
In this case, you may not get a complete Sitemap from a tool that
operates by following static links. (Some of your pages appear to be
linked primarily through menu-script code rather than static links.)
You can create your Sitemap manually instead.

To create your Sitemap:
Create a text file named "sitemap.txt". In that file, list all of the
URLs of pages that are located within the "materials" section of your
site. (Also include the URLs of the PDF files located in that
section.) Enter one URL per line.

For more information about the requirements for a Sitemap text file,
scroll-down the following page (skipping the XML example for now), and
read the applicable guidelines under the "Text file" bullet item.

http://www.google.com/support/webmasters/bin/answer.py?answer=183668

Upload your completed "sitemap.txt" file to the following location on
your site:

http://www.colonie.org/library/digitalLibrary/materials/sitemap.txt

Next, go to the Webmaster Tools:

https://www.google.com/webmasters/tools/

(You may be asked to sign-in again.)
Click the "Add a site" button, and enter the home URL of the part of
the web site that you manage:

http://www.colonie.org/library/digitalLibrary/materials/

The "Verify ownership" page will appear. There you can verify your
ownership of your part of the site (in order to gain full access to
the Webmaster Tools). (Note: Keep the "Verify ownership" page open in
your web browser while you complete the next step.)

The default "Verification method" uses a "Meta tag". Copy-and-paste
the provided meta-tag code into the <head> section of your
"index.html" page:

http://www.colonie.org/library/digitalLibrary/materials/index.html

After you've copied the meta-tag into the <head> section of that page,
return to the "Verify ownership" page and click the "Verify" button.

After completing verification, you can submit your Sitemap. Return to
the Webmaster Tools home page:

https://www.google.com/webmasters/tools/

Your site should be listed in blue text. (If it is listed in gray,
you haven't successfully completed the Verification step; try again.)

Click your verified site's name,
to enter the Webmaster Tools "Dashboard".
Click "Site configuration" (in the left column).
Click "Sitemaps". Click the "Submit a Sitemap" button.
Enter the URL of your uploaded "sitemap.txt" file:

http://www.colonie.org/library/digitalLibrary/materials/sitemap.txt

Sitemap processing might take several minutes (delays vary). Reload
the Webmaster Tools "Sitemaps" page to check status. After successful
processing a green check-mark appears.

.

After your Sitemap has been processed, you can request On-Demand
Indexing for your Custom Search Engine. Return to your "My Search
Engines" page:

http://www.google.com/cse/manage/all

Click the "control panel" link.
Click "Indexing" (in the left column).
Your Sitemap should be listed under "Identified Sitemaps".

Under "On-demand indexing using Sitemaps", click the "Select a
Sitemap" drop-down menu, and select your Sitemap's name from that
menu. (If the Sitemap is not listed in the menu, choose "Custom" and
enter the sitemap's URL.) Click the "Index Now" button. According to
documentation, on-demand indexing may take up to 24 hours to complete.

http://www.google.com/support/customsearch/bin/answer.py?answer=115959

.

Custom Search discussion forum:

http://www.google.com/support/forum/p/customsearch/
http://www.google.com/support/forum/p/customsearch/browse

-- omr

Paul

unread,
Jul 27, 2010, 6:36:28 PM7/27/10
to Google AJAX APIs
Thanks a lot OMR. That is great information. I am going to try it all
tomorrow morning.

One question: I have a Javascript client side include file in a
directory above the "materials" directory that all the pages include
for the left nav. bar. I am assuming that because this file is above
the materials directory and is not included in the sitemap, it will
not be included in the search?

Paul

Paul

unread,
Jul 28, 2010, 8:12:43 AM7/28/10
to Google AJAX APIs
There appears to be an issue with the Google Custom Search form page.
I am entering all the needed information in the "set up your search
engine" tab, but it keeps re-displaying the page either with a
fictitious error or no error noted. I cannot get by this.

There does not seem to be a way of contacting them about this. Has
anyone experienced this?

Paul


On Jul 27, 1:36 pm, omr <omr99...@yahoo.com> wrote:

omr

unread,
Jul 28, 2010, 9:12:04 AM7/28/10
to Google AJAX APIs
I'm not encountering that problem in any of the several current
browsers installed on my Windows PC.

What browser type and version are you using?

I might suggest that you try a current version of another browser,
such as Firefox or Chrome, and see if the problem still occurs.

Firefox:
http://www.mozilla.com/en-US/firefox/

Chrome:
http://www.google.com/chrome/

-- omr

omr

unread,
Jul 28, 2010, 9:24:18 AM7/28/10
to Google AJAX APIs
BTW:
I expect that we are going to continue discussing Custom Search issues
that are *not primarily* related to the AJAX Search API. After you
post your next reply, let's move over to the Custom Search forum.

http://www.google.com/support/forum/p/customsearch/
http://www.google.com/support/forum/p/customsearch/browse

We can't move this thread (or any of these posts) to that forum. But
you (or I) can start a new thread there to continue discussing Custom
Search issues.

-- omr
Reply all
Reply to author
Forward
0 new messages