Open GoogleCodeExporter opened 9 years ago
It does not work for BlogsSearch either.
Original comment by nbaa...@gmail.com
on 13 Apr 2010 at 9:08
Attachments:
Is this what you're looking for?
News: http://code.google.com/apis/ajax/playground/?exp=search#search_by_date
Blog:
http://code.google.com/apis/ajax/playground/?exp=search#order_search_results_by_
date
Original comment by jrgeer...@gmail.com
on 13 Apr 2010 at 11:37
Thanks for advice:
I managed to get the News sorted on date like this
var newsSearch = new google.search.NewsSearch();
var extendedArgs = google.search.Search.RESTRICT_EXTENDED_ARGS;
newsSearch.setRestriction(extendedArgs, {'scoring':'d'});
searchControl.addSearcher(newsSearch, options);
But I do not understand why it can not be done like this:
var searchControl = new google.search.SearchControl();
searchControl.setResultOrder(google.search.Search.ORDER_BY_DATE);
searchControl.addSearcher(new google.search.NewsSearch());
The blogs version I do not get working. According to the documentation this
should
work but it does not.
var searchControl = new google.search.SearchControl();
searchControl.setResultOrder(google.search.Search.ORDER_BY_DATE);
searchControl.addSearcher(new google.search.BlogSearch());
Original comment by nbaa...@gmail.com
on 14 Apr 2010 at 11:17
The reason that searchControl.setResultOrder(...) doesn't work is that the
SearchControl does not have a
setResultOrder method. You have to use the .setResultOrder method of the
searchers directly. Something like this
should work:
var searchControl = new google.search.SearchControl;
var newsSearch=new google.search.NewsSearch;
newsSearch.setResultOrder(google.search.Search.ORDER_BY_DATE);
searchControl.addSearcher(newsSearch)
Original comment by jrgeer...@gmail.com
on 14 Apr 2010 at 12:33
Yes, but should it not have this method!
So all searchers are order by date.
So not only BlogSearch has this method (that does not work) but all of them and
hopefully working then.
// create a search control
var searchControl = new google.search.SearchControl(null);
searchControl.setResultOrder(google.search.Search.ORDER_BY_DATE);
// add in a full set of searchers
searchControl.addSearcher(new google.search.LocalSearch());
searchControl.addSearcher(new google.search.WebSearch());
searchControl.addSearcher(new google.search.VideoSearch());
searchControl.addSearcher(new google.search.BlogSearch());
searchControl.addSearcher(new google.search.NewsSearch());
searchControl.addSearcher(new google.search.ImageSearch());
searchControl.addSearcher(new google.search.BookSearch());
searchControl.addSearcher(new google.search.PatentSearch());
// tell the searcher to draw itself and tell it where to attach
// Note that an element must exist within the HTML document with id
"search_control"
searchControl.draw(document.getElementById("search_control"));
Original comment by nbaa...@gmail.com
on 14 Apr 2010 at 6:18
Original issue reported on code.google.com by
nbaa...@gmail.com
on 13 Apr 2010 at 8:46