Custom Google Search – setQueryAddition

Google Custom Search service provide customized search for web on your site or blog.
We can filter Google Custom Search results on filetype like PDF 🙂

You have to initiate below JavaScript on event…

// create a tabbed mode search control
var tabbed = new GSearchControl();

tabbed.setResultSetSize(GSearch.LARGE_RESULTSET);

// add an additional term to the query
// in this case filetype:pdf
var searcher = new GwebSearch();

//searcher.setResultSetSize(GSearch.LARGE_RESULTSET);

searcher.setUserDefinedLabel("svnlabs (pdf)");
searcher.setQueryAddition("filetype:pdf");

//searcher.setResultSetSize(GSearch.LARGE_RESULTSET);

var searcherOptions = new GsearcherOptions();
searcherOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);

tabbed.addSearcher(searcher, searcherOptions);

// draw in tabbed layout mode
var drawOptions = new GdrawOptions();
drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);
tabbed.draw(document.getElementById("search_control_tabbed"), drawOptions);

// PHP keyword in search box
tabbed.execute("PHP");

Every day do one thing that you think you cannot do. Soon you will realize that there is nothing that you can not do…