I have been given a set of (approved) requirements and an already approved solution to implement Google Custom Search into an existing website.
This website has the following:
-
Jobs
- Category 1
- Category 2
- Category 3
-
Normal pages
- Category 1
- Category 2
- Category 3
The requirement of the search functionality is that people can use CheckBoxes to filter results. So if the below was true:
[x] Category 1
[ ] Category 2
[x] Category 3
Then no pages would be shown from Category 2. However, there is also:
[x] Show jobs only
How am I able to implement this via Google Custom Search? I’ve read about PageMap, using <meta> tags, etc.. however I cannot understand how I am to filter results based on these.. ?
I looked here: Google custom search API – sorting / filter
However it doesn’t appear to answer my concerns. I’m still a bit lost in the documentation.
Is this sort of thing possible? Does anyone have any links to some more thorough examples?
I had a thought to try in-memory filtering.. however if Google just happens to throw back a 1 Job page in 10 results while the [x] Show jobs only checkbox is checked.. then the user will only get 1 result on the page.
I am leaning towards the XML-based result set using the Custom Search Engine.. however if that needs to change I’m open to suggestions.
Any advice appreciated.
I have managed to figure this out … Only by lots of trial and error.
To begin, an example
PageMapelement in the XML response:Google’s filtering will only match individual words separated by spaces, special characters, etc. So, if I wanted to search for a “creator” with “CS5” in it, I would use this query string:
The above “type” and “name” refer to the
DataObjectandAttributeelement attribute names. The last part is the word you want to filter by.So now I should be able to dump the following to to a page in Category 1:
Or.. for a job:
..and use a query such as this:
The first example returns any pages with a meta tag name of “category” that contains the value “Category1” OR “Category3”.
Hopefully this answer saves someone from tearing their hair out.. like I almost did.