Export search results to CSV
Hi Low,
I'm just adding some Low Search forms to an intranet, and it would be great if there was a Low Search variable that outputted a link to enable the current search results to be exported to CSV/Excel.
I believe that Zenbu recently added this feature in the CP, but there's no options (as far as I know) to combine custom searching/filtering and exporting on the front end. I know Export It allows exporting entries on the front end, but only with pre-defined criteria/results.
I'm currently using DataTables with the TableTools plugin to export what is visible in a search results table on screen, but the downside of this is that you can only export 1000-2000 results before the whole thing starts to slow down.
Anyway, just posting this feature request and use case for info.
Thanks,
Ste
Replies
Low 26 Feb 2013 09:19
Low Search uses the channel:entries module to generate the results, so with or without a specific tag, the slowness you're experiencing is simply due to EE's native constraints with dealing with large amounts of entries.
The results would have to run through the template engine in some way or another, so your best bet would be to create a specific lean template for displaying a CSV-file and try to optimize it as best you can. Then use PHP in the template to force a download instead of displaying it in the browser.
Stephen 26 Feb 2013 18:55
Hi Low,
Thanks for the pointers on this and the suggestion of a workaround.
I guess the perfect solution (away from adding all sorts of export functionality to Low Search) would be if the Export It add-on could somehow access the Low Search results query in order to generate its own export file (as I think it generates the exports outside of the constraints of the template engine).
I might be talking gibberish about what is possible from a technical point of view (whether EE constraints, add-on constraints, etc), but it would sure be nice to the end user like me! :-)
Thanks,
Ste
Low 26 Feb 2013 19:34
Because of the way Low Search utilises the native channel:entries tag, Low Search cannot generate a its own export file. It doesn't know the final list of results, because the native channel:entries tag takes care of a lot of filtering as well.
Therefore, using the template engine is inevitable for generating the results, whether in HTML or CSV format.
Stephen 17 Dec 2013 14:50
Hi Low,
This request to have the option to export Low Search results to a CSV file keeps coming up with my client.
In your last message, you said that Low Search cannot generate its own export file as it doesn't know the final list of results, as the native channel:entries tag takes care of a lot of filtering as well.
I just had a thought though (which may be more EE related than Low Search related, but I figured you might know anyway) - do you know if it's possible to output the final query that's used to output the results? It just wondered if we could grab that query and pass to our own PHP script, to then generate an export.
Thanks,
Stephen
Low 17 Dec 2013 16:26
The last query performed after I get the results isn't the query used to get all the channel entry data. In fact, I'm not sure there is a single one that does that. Rather, it's a composite of several queries that are combined in PHP to get to the final result.
Also, after the entries are queried, possible extensions kick in (things like Matrix spring to mind), which will then be the last query.
All in all, I'm afraid your idea won't work. I still think using a template for the results is your best option.