Re: V1 API - CustomSearch controls mostly work but Image Search.SetRestrictions fail - what am I missing? (Code linked below)

71 views
Skip to first unread message

Jeremy Geerdes

unread,
Nov 13, 2012, 12:10:56 PM11/13/12
to google-ajax...@googlegroups.com
Try putting the .setRestriction call AFTER the .draw call.

jg

On Tue, Nov 13, 2012 at 10:46 AM, headtailgrep <steveho...@gmail.com> wrote:
Hi all,
I'm racking my brain trying to get ImageSearch to return only large or extra large images, everything else under my control seems to be fine.
Ultimate goal: Restrict to my site only (working), Display search results only (working), return only X number of results (6 or 7) (working), only show images (working) and popup layout (working).
But my search control is returning results for images at 200x150 AND high resolution (large, Xlarge) images. I want to display high res image results only. No matter what I do to try and control using ImageSearch.SetRestriction it fails to behave as expected.
Here's a pastebin for proper formatting:
Ignore the commented out code, it is redundant.
What is confusing me is as follows:
I define and call the Custom Search Control at line 19
at line 25 I call the DrawOptions method and these successfully stick
So based on line 25, I define the ImageSearch method and set the options at line 30.
Then I Draw and Execute the control at 32 and 33.
In the arguments i'm adding the variables/methods I called at 25/28. Drawoptions successfully update but ImageSearch.* options fail to work.
I'm certainly missing something. Any tips highly appreciated with thanks.

--
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
To view this message on the web, visit
https://groups.google.com/d/msg/google-ajax-search-api/-/0GdVIhTCueoJ
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en



--
Jeremy R. Geerdes
Generally Cool Guy
Des Moines, IA

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

headtailgrep

unread,
Nov 13, 2012, 1:49:37 PM11/13/12
to google-ajax...@googlegroups.com
No dice. Going to play with that idea though ;)

headtailgrep

unread,
Nov 13, 2012, 3:07:50 PM11/13/12
to google-ajax...@googlegroups.com
 
also tried
 
 customSearchOptions['google.search.Search.RESTRICT_EXTENDED_ARGS'] = {
            'imgsz' : 'xxlarge'
    };
^ which is passed to new CustomSearchControl in the Options
 
and it also had no effect.
 
For kicks I also tried a query string (which I use elsewhere in the site) with &imgsz=xxlarge and it also had no effect, the image search still returne 200x150 image results.
 
No matter what I try I cannot eliminate the 150x200 image results. These are the ones I want to eliminate :)

headtailgrep

unread,
Nov 14, 2012, 10:44:21 AM11/14/12
to google-ajax...@googlegroups.com
I've had no luck with controlling image size - It turns out the API allows  DrawOptions as the second argument of Execute, but no other allowances are made. So my method is not correct as shown in Pastebin.
 
Either way no permutations of how and when to call .SetRestriction and CustomSearchControl.draw have resulted in any image size controls.
 
I get the impression that an ImageSearch object is to be treated differently and executed differently. I could be wrong on that point but that's how it seems to me :(
 
CustomSearchControl.execute can also haev three paramaters - 1) the query 2) page number, 3) additional control
 
From the API it states for 3: "Specifies additional arguments to append to the URL. It is a one-time modification used only in this request."
 
I have attempted to use Query arguments (such as imgsz=xxlarge or &imgsz=xxlarge) - I assume this may be what they mean, but it had no effect :)
 
I am wondering if the Image Size options to not work in a CSE.
 
 

headtailgrep

unread,
Nov 14, 2012, 10:46:10 AM11/14/12
to google-ajax...@googlegroups.com

On Wednesday, 14 November 2012 10:44:21 UTC-5, headtailgrep wrote:
I've had no luck with controlling image size - It turns out the API allows  DrawOptions as the second argument of Execute, but no other allowances are made. So my method is not correct as shown in Pastebin.
 
Either way no permutations of how and when to call .SetRestriction and CustomSearchControl.draw have resulted in any image size controls.
 
I get the impression that an ImageSearch object is to be treated differently and executed differently. I could be wrong on that point but that's how it seems to me :(
 
CustomSearchControl.execute can also has three paramaters - 1) the query 2) page number, 3) additional arguments

headtailgrep

unread,
Nov 19, 2012, 11:00:39 AM11/19/12
to google-ajax...@googlegroups.com
This is still not working, but I have a workaround: append google search operators to the query solved my problem for now. It's not elegant (as it leaves holes open for resolutions not covered) but for example, in .execute i append to the search string: "-imagesize:200x150 -imagesize:930x170 -imagesize:728x90 -imagesize:720x90 -imagesize16x16
which worked for the most part. 16x16 was not filtered though ;)
 
Thank you everyone for viewing , if you do have ideas i'm still game to program the elegant solution if any suggestions arise. 
 
 
Reply all
Reply to author
Forward
0 new messages