6/29/11
Original Poster
rs2010Can you set a specific refinement label as the default result set?
Hi, i'm wondering if it's possible to set a refinement label as the default result listing? For example, a user enters a query on a Google CS that has two refinement labels. Currently the search will load the results of both, but i want to load just the results of one by default, and have the other label there as another option for users who may be looking for something else.
thanks!
thanks!
Community content may not be verified or up-to-date. Learn more.
All Replies (7)

7/15/11
cosgcommI have the exact same question. Hopefully an answer will be posted soon!

10/19/11
JcmesserschmidtYou can use background labels to do this.

11/28/11
Google userAlthough it's undocumented by Google on this page:
http://code.google.com/intl/en/apis/customsearch/docs/js/cselement-reference.html
I looked through the JavaScript source file and found it IS possible ( see below ).
This will set the default refinement label, and change the tab. Perfecto!
http://code.google.com/intl/en/apis/customsearch/docs/js/cselement-reference.html
I looked through the JavaScript source file and found it IS possible ( see below ).
This will set the default refinement label, and change the tab. Perfecto!
var searchOps = {'defaultToRefinement': 'my_refinement_label'};
var searcher = new google.search.CustomSearchControl('[Custom Search ID]', searchOps);

12/1/11
hxu-cseWow! You guys rock! Yes, setting the default refinement label hasn't been documented yet (we are working on a more complete Element documentation including this), and it can be done exactly as you discovered.

12/3/11
toyNNNice - I've been searching around for just this ability to change the default search refinement label. Excellent and works perfectly and appears to semi-officially indorsed as a preferred method. Thanks for posting!
Here is the code I used for a results only page that's calling another function to parse the search query,
Here is the code I used for a results only page that's calling another function to parse the search query,
google.load('search', '1', { language: 'en' });
google.setOnLoadCallback(function () {
var searchOps = { 'defaultToRefinement': 'my_refinement_label' };
var customSearchControl = new google.search.CustomSearchControl('My CSE ID', searchOps);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchResultsOnly();
customSearchControl.draw('cse', options);
var queryFromUrl = parseQueryFromUrl();
if (queryFromUrl) {
customSearchControl.execute(queryFromUrl);
}
}, true);

2/9/12
hxu-cseAnd that option is documented now:
http://code.google.com/intl/en/apis/customsearch/docs/js/cselement-reference.html (search for "defaultToRefinement")

5/14/17
cregox@hxu-cse is still right! :) 😄search for "defaultToRefinement" and, today, it brought me to https://developers.google.com/custom-search/docs/elementand I've used it as this, on my page's code:<gcse:search defaultToRefinement="main"></gcse:search>now, wished I knew how to keep the formatting here!2
This question is locked and replying has been disabled. Still have questions? Ask the Help Community.
Badges
Some community members might have badges that indicate their identity or level of participation in a community.
Community content may not be verified or up-to-date. Learn more.
Levels
Member levels indicate a user's level of participation in a forum. The greater the participation, the higher the level. Everyone starts at level 1 and can rise to level 10. These activities can increase your level in a forum:
- Post an answer.
- Having your answer selected as the best answer.
- Having your post rated as helpful.
- Vote up a post.
- Correctly mark a topic or post as abuse.
Having a post marked and removed as abuse will slow a user's advance in levels.
View profile in forum?
To view this member's profile, you need to leave the current Help page.
Report abuse in forum?
This comment originated in the Google Product Forum. To report abuse, you need to leave the current Help page.
Reply in forum?
This comment originated in the Google Product Forum. To reply, you need to leave the current Help page.