現在、私たちの組織は Google カスタム検索エンジンを使用して自動提案を提供しており、CSE で約 3 つの絞り込みラベルを構成しています。以前は、WebSearch と SearchControl を使用しており、WebSearch には絞り込みラベルを具体的に選択できる setSiteRestriction メソッドがあります: - http://code.google.com/apis/websearch/docs/reference.html#_class_GwebSearch
前のコード例:
var searchControl = new google.search.SearchControl();
var webSearch = new google.search.WebSearch();
//Refinement allows us to tell Google which specific sites to search
var refinement="Support";
//filter custom search and currently there are 3 refinements
(some other variables declaration here including 'product')
switch(product)
{
case "10000":
refinement = "Support1";
break;
case "10200":
refinement = "Support1";
break;
case "10001":
refinement = "Support2";
break;
default:
break;
}
/*this is the code to fill in the custom search. The refinement was set above - either "Support", "Support1", or "Support2".*/
webSearch.setSiteRestriction('cseId', refinement);
......
ただし、現在、非推奨の WebSearch を置き換えるために CustomSearchControl ツールに移行していますが、switch case ステートメントの値に基づいて絞り込みラベルを具体的に選択する方法が見つからなかったようです。ここですぐに助けが必要です。関連するドキュメントがあれば、私に指摘していただければ幸いです。ありがとう!:)