Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export SOLR data to CSV or EXCEL

Tags:

solr

I need to export solr data to EXCEL or CSV. I have SOLR code with millions of records and I need a way to export them by a certain query to CSV/EXCEL. In addition I need to control the headers inside the EXCEL.

What do you suggest? Is there a 3rd party API that does it? Should I use CSV format and just extract them and then manipulate the csv?

like image 970
Pinidbest Avatar asked Oct 01 '17 08:10

Pinidbest


People also ask

How do I export data from Apache SOLR?

You can use /export to make requests to export the result set of a query. All queries must include sort and fl parameters, or the query will return an error. Filter queries are also supported. The supported response writers are json and javabin .

How do I save a CSV file as a model?

Procedure. In the DA Explorer view, right-click the connection name that contains the model that you want to export. Click Export to File as CSV. In the Export to CSV window, select the location where you want to save the data and click Save.


2 Answers

The best tool to export your Solr data is the /export request handler [1].

Unfortunately, from the official Solr documentation, csv is not supported as an output.

Json is the default. If you can manage Json transformations to obtain the data format you want in CSV, the /export is definitely the best way to proceed. If performance is not an issue, the standard select request handler using the CSV response writer should do the trick [2].

http:/localhost:8983/solr/collection1/select?q=*:*&wt=csv&indent=true&rows=N

[1] https://lucene.apache.org/solr/guide/6_6/exporting-result-sets.html

[2] http:/localhost:8886/solr/tech/select?q=:&wt=csv&indent=true

like image 136
Alessandro Benedetti Avatar answered Sep 16 '22 20:09

Alessandro Benedetti


You may use Solr select endpoint to extract all documents with q=*:* and csv responseWriter.

Example:
http:/localhost:8886/solr/tech/select?q=*:*&wt=csv&indent=true

More details about csv ResponseWriter can be found here.

like image 29
Shubhangi Avatar answered Sep 19 '22 20:09

Shubhangi