Wednesday 17 June 2009

Customizing Bing (on your site)

It's fairly easy to create a site-specific, bing-powered search box, using the basic wizard at www.bing.com/siteowner.

However, it turned out to be less obvious how to 'customize' it's behaviour... specifically I wanted the search to search 'sites in Australia' by default. The final result is shown below, and you can try it here



Working with Advanced Queries in the Windows Live Search Box provides some hints about how you can customize the javascript var WLSearchBoxConfiguration={...} which controls how the search box works.

By default it looks like this
var WLSearchBoxConfiguration=
{
"global":{
"serverDNS":"www.bing.com",
"market":"en-AU"
},
"appearance":{
"autoHideTopControl":false,
"width":600,
"height":400,
"theme":"Blue"
},
"scopes":[
{
"type":"web",
"caption":"Web",
"searchParam":""
}
]
}
which provides a simple web search. To force the search to be "only for sites from Australia" we needed to add a new scope with a searchParam set:
"searchParam":"loc:AU"

Restricting to a specific site/domain is more obvious:
"searchParam": "site:conceptdev.blogspot.com"


It ends up looking like this:
var WLSearchBoxConfiguration=
{
"global":{
"serverDNS":"www.bing.com",
"market":"en-AU"
},
"appearance":{
"autoHideTopControl":false,
"width":600,
"height":400,
"theme":"Blue"
},
"scopes": [
{
"type": "web",
"caption": "this site",
"searchParam": "site:conceptdevelopment.net"
}
,
{
"type": "web",
"caption": "ConceptDev Blog",
"searchParam": "site:conceptdev.blogspot.com"
}
,
{
"type":"web",
"caption":"Web (Australia)",
"searchParam":"loc:AU"
}
,
{
"type":"web",
"caption":"Web (all)",
"searchParam":""
}
]
}
It doesn't look like you need to worry too much about the ASCII-Hex encoding for simple characters (although if you want to encode them, there are plenty of tools).

No comments:

Post a Comment

Note: only a member of this blog may post a comment.