Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (51 sloc) 2.099 kb
3d8e352 sample tables from the blog post
Samuel Pullara authored
1 <?xml version="1.0" encoding="UTF-8"?>
2 <table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
3 <meta>
4 <author>Nagesh Susarla</author>
5 <documentationURL>See search.web and search.images for more details</documentationURL>
c90de4b Add a paging model to search.imageweb
Srinagesh Susarla authored
6 <sampleQuery>select * from {table} where query='pizza'</sampleQuery>
3d8e352 sample tables from the blog post
Samuel Pullara authored
7 </meta>
8 <bindings>
9 <select itemPath="results.result" produces="XML">
10 <urls>
11 <url></url>
12 </urls>
c90de4b Add a paging model to search.imageweb
Srinagesh Susarla authored
13 <paging model="offset">
14 <start id="start" default="0" />
15 <pagesize id="count" max="50" />
16 <total default="10"/>
17 </paging>
3d8e352 sample tables from the blog post
Samuel Pullara authored
18 <inputs>
e326042 fix search.imageweb to use a variable
Srinagesh Susarla authored
19 <key id="query" type="xs:string" paramType="variable" required="true"/>
3d8e352 sample tables from the blog post
Samuel Pullara authored
20 </inputs>
21 <execute><![CDATA[
22
23 var qs = query;
c90de4b Add a paging model to search.imageweb
Srinagesh Susarla authored
24 var webquery = 'select * from search.web(' + start + ',' + count + ') where query=@query';
3d8e352 sample tables from the blog post
Samuel Pullara authored
25
c90de4b Add a paging model to search.imageweb
Srinagesh Susarla authored
26 var search = y.query(webquery, {query: qs}).results;
3d8e352 sample tables from the blog post
Samuel Pullara authored
27 var images = [];
28 default xml namespace='http://www.inktomi.com/';
af0def1 Search for images in the actual site rather than the exact searchurl. Th...
Srinagesh Susarla authored
29
30 for each (var result in search.result) {
31 var theUrl = result.url;
32 // For any given URL from search only get the domain
33 // and use that as part of the search for images. This makes
34 // imagesearch much more richer
35 var idx = theUrl.indexOf("/", "http://".length);
36 if (idx > 0) {
37 theUrl = theUrl.substring(0, idx);
38 }
39
40 images.push(y.query('select * from search.images(1) where query=@query and url=@url', {url:theUrl, query:qs}));
3d8e352 sample tables from the blog post
Samuel Pullara authored
41 }
42
43 var i = 0;
44
45 for each (var result in search.result) {
46 var image = images[i].results.result;
47 if (image) {
48 result.image = <image>{image}</image>;
49 }
50 i++;
51 }
52
53 response.object = search;
54 ]]>
55 </execute>
56 </select>
57 </bindings>
58 </table>
Something went wrong with that request. Please try again.