providing an option to download search results as csv

236 views
Skip to first unread message

Senthil Mani

unread,
Apr 4, 2012, 6:18:24 AM4/4/12
to ajax...@googlegroups.com
Hi 

I wanted to add an option to the Current Selection - "Download search results as csv". SOLR allows the response to come in csv format by setting &wt=csv. My intent to achieve is when user click on this download option, the current query's results will be saved as CSV File and downloaded to the user's machine. 

So in the CurrentSearchWidget.js i added an extra link as follows

links.push($('<a href="#"/>').text('Download search result as CSV').click(self.downloadCSV()));

also added the downloadCSV() function as follows 

 downloadCSV: function(){

 var self = this;

    return function () {

    debugger;

    self.manager.store.remove('wt');

    self.manager.store.addByValue('wt''csv');

    self.manager.doRequest(0);

    return false;

    };

  }

Also made sure in doRequest() method of the manager to not invoke any widget's before Request method if the 'wt' value is 'csv'. This way I could avoid the result widget not clearing off its existing content. However i expected the call flow to reach the afterRequest() method of the ResultWidget.js - where I could handle the response from SOLR. However It does not reach there, and request just dies.  When i debugged using firebug - the manager.doRequest() happens and after than it goes to jquery.min.js and the request just dies. Can someone help here?

James McKinney

unread,
Apr 4, 2012, 6:46:37 AM4/4/12
to ajax...@googlegroups.com
I think you can just create a link with the HREF attribute:

Manager.solrUrl + Manager.servlet + '?' + Manager.store.string() + '&wt=csv'

Doing it with parameter store, etc. will be very hard.

Senthil Mani

unread,
Apr 6, 2012, 5:22:53 AM4/6/12
to ajax...@googlegroups.com

Thanks James,
 Thats precisely what i did after going over the Manager js.

Thanks for your reply too.

I have an another question (but) will post is as a separate topic

themr2d...@gmail.com

unread,
Nov 15, 2013, 6:04:02 PM11/15/13
to ajax...@googlegroups.com
Would you still recommend doing this if you are trying to download a csv with millions of records?

I am finding that I can only get about 10k before solr gives out. Even going through the Solr UI it has troubles.

James McKinney

unread,
Nov 15, 2013, 6:15:52 PM11/15/13
to ajax...@googlegroups.com
Hmm, if it's an issue with Solr, maybe ask the Solr lists: 



--
You received this message because you are subscribed to the Google Groups "ajax-solr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ajax-solr+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Zoe Zhang

unread,
Jul 14, 2014, 5:14:05 PM7/14/14
to ajax...@googlegroups.com
Hi James,

I'm a newbie to ajax and solr... wanna implement this functionality,  can you give more detail on how and where do I create this HREF and pass to the html?

James McKinney

unread,
Jul 14, 2014, 6:31:35 PM7/14/14
to ajax...@googlegroups.com
<a href=“javascript:Manager.solrUrl+Manager.servlet+'?'+Manager.store.string()+'&wt=csv’”>link</a>


--
You received this message because you are subscribed to the Google Groups "ajax-solr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ajax-solr+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages