Categories: Implementation :

Can we give users "Advanced Search" panel similar to Google.com for date

Showing 1-8 of 8 messages
Can we give users "Advanced Search" panel similar to Google.com for date RudyWebmaster 3/4/11 2:24 PM
Hi There:
 
My clients would like a complex site search engine that has some options like those found in Google.com in the Advanced Search panel, epecially the options for sort by date.
 
Is it possible to to create such a panel, with some of ththose options on it. If so can you direct me to examples or tutorials please.
 
Thanks very much,
RP
Re: Can we give users "Advanced Search" panel similar to Google.com for date searchtools 3/7/11 12:57 PM
Dates are generally a problem in search, as servers lie about the date of the document modification (too old or too new) and search engines often track the dates they crawled rather than the updates to the content.(1).  If you own the content, you can program your server to send the correct date in the HTTP header.  My tests indicate that Google doesn't use dates in metadata fields or HTTP equiv tags, just the update date in the server, so be sure you are sending correctly.

The Google CSE/SSE can be nudged into doing the most recent day, week, month, year, etc. using the as_qdr advanced operator[2].  From this list, I got some code[2] for a drop-down menu to do this (iframe and hosted forms in the CSE, simple JavaScript in the SSE), and I can confirm that it works.  I'm still trying to add it to the JavaScript for the Element.

<pre>
  <select name="as_qdr">
  <option value="all">Any time</option>
  <option value="d">Past 24 hours</option>
  <option value="d2">Past 2 days</option>
  <option value="w">Past week</option>
  <option value="w2">Past 2 weeks</option>
  <option value="m">Past month</option>
  <option value="m2">Past 2 months</option>
  <option value="m6">Past 6 months</option>
  <option value="y">Past year</option>
  <option value="y2">Past 2 years</option>
  <option value="y5">Past 5 years</option>
  <option value="y10">Past 10 years</option>
  </select>
</pre>
There used to be some kind of daterange operator, but it seems to be gone now.  In the advanced search for google.com, you can choose a date range and the parameter is tbs=cdr -- but I haven't managed to wedge it into the CSE yet.

Hope that helps

Avi

PS - there are alternatives to this search engine, some free with ads.  They are less constrained in some areas than Google, they aren't hit as much by spam, so you may find them useful -- I have some info at searchtools.com
Re: Can we give users "Advanced Search" panel similar to Google.com for date searchtools 3/7/11 1:00 PM
Sorry, a couple more things: please ignore the &gt;pre&lt; tag, the system was making the menu show up instead of the code.  Also, it lost my references, so see below.
Re: Can we give users "Advanced Search" panel similar to Google.com for date rudypohl 3/7/11 1:21 PM
Thanks Avi:
 
I've been on your site, lots of good info there. I am present using Ksearch on a site but the client want more control regarding date searches.
 
Thanks,
ROMP
Re: Can we give users "Advanced Search" panel similar to Google.com for date RudyWebmaster 3/8/11 5:10 AM
Hi again Avi:
 
Below is my cse code. Is it possible for you to tell me how the... as_qdr advanced operator .... you mention above should be insert in my code to allow the drop down list to work?
 
<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
  google.setOnLoadCallback(function() {
    var customSearchControl = new google.search.CustomSearchControl('010646929552949435218:dcgnkyhkwk0');
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script>
  </div>
 
Thanks,
RMP
Re: Can we give users "Advanced Search" panel similar to Google.com for date searchtools 3/10/11 12:35 PM
There are two things: rendering a menu in the JavaScript element, and having that menu send something useful.  

The first one is a complex bit of programming that is described in a useful Google AJAX APIs Group post (1)

The other might work using a parameter called "RESTRICT_EXTENDED_ARGS" but it's not really documented.  This blog post mentions it, but I get errors when I try this: http://googlecustomsearch.blogspot.com/2010/12/more-power-to-metadata.html

Best of luck!

Avi
SearchTools.com
Re: Can we give users "Advanced Search" panel similar to Google.com for date omr 3/10/11 7:31 PM

IIUC, the "hard sorting" option (using the "date-sdate" example syntax) requires PageMaps, each containing a DataObject with an Attribute that indicates the page's date.

In the "date-sdate" syntax, the first part (e.g. "date") must match the name of that DataObject, and the second part (e.g. "sdate") must match the name of the Attribute whose value indicates the page date on which to sort.

Documentation:

Please see the section titled "Structured Search in the Custom Search Element" at the bottom of this page:

http://code.google.com/apis/customsearch/docs/structured_search.html#structured_search_element

As an example that documentation describes the SignOnSanDiego.com site's use of hard sorting.

(See also the "Sort by Attribute" section elsewhere on that page.)

(Note: If you plan to add new PageMap data to your pages, you may also want to submit a complete Sitemap, and consider using On-Demand Indexing to re-index the modified pages as quickly as possible.)

.

If the pages you are searching do NOT contain PageMaps with attributes indicating the page publication dates, then IIUC the "hard sorting" option won't work.

As an alternative way to attempt a *rough* *approximate* sort, you can try using the "recent4" built-in recency label.  That label is mentioned in this documentation:

http://code.google.com/intl/en/apis/customsearch/docs/ref_prebuiltlabels.html#recency

To use the "recent4" label with the Custom Search Element, try something like this:

  customSearchControl.setSearchStartingCallback(
    this,
    function(control, searcher, query) {
      searcher.setQueryAddition(
        'more:recent4');
    });

.

(Note:  This post is primarily in response to Avi's last reply above.
I haven't attempted to answer the original poster's question about user-interface implementation.)

-- omr

Re: Can we give users "Advanced Search" panel similar to Google.com for date ST Nathan 8/9/12 3:02 PM
"In the advanced search for google.com, you can choose a date range and the parameter is 
tbs=cdr -- but I haven't managed to wedge it into the CSE yet."

Hi Avi,

Have you by any chance found a way to wedge that tbs parameter in yet?  Google's added a new 'Sites with images' feature, apparently by themselves wedging it into the tbs parameter.  (So if you turn that on and filter by date, you'll get something like &tbs=img:1,qdr:m .)  I'd love to filter by pages with images, but like you can't find a way to get this parameter into an (API-based) CSE.