Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export solr result into a text file?

Tags:

export

solr

I needs to export doc_id, all fields, socr, rank of one search result to evaluate the results. How can I do this in solr?

like image 207
Jun Avatar asked Nov 18 '11 01:11

Jun


3 Answers

Solr provides you with a CSV Response writer, which will help you to export the results of solr in an csv file.

http://localhost:8983/solr/select?q=ipod&fl=id,cat,name,popularity,price,score&wt=csv

All the fields queried would be returned by Solr in proper format.

like image 55
Jayendra Avatar answered Dec 20 '22 12:12

Jayendra


This has nothing to do with SOLR. When you make a SOLR query over http, then SOLR does the search and returns the results to you in your desired format. The default is XML but lots of people specify wt=json to get results in json format. If you want this result in a text file, then make your search client put it there.

In the browser, File -> Save As.

But most people who want this use curl as the client and use the -o option like this:

curl -o result1.xml 'http://solr.local:8080/solr/stuff/select?indent=on&version=2.2&q=fish&fq=&start=0&rows=10&fl=*%2Cscore&qt=&wt=&explainOther=&hl.fl='

Note the single quotes around the URL due to the use of & characters.

like image 42
Michael Dillon Avatar answered Dec 20 '22 12:12

Michael Dillon


There is not a built in export function in Solr. The easiest way would be to query your Solr instance and evaluate the XML result. Check out Querying Data in the Solr Tutorial for details on how to query a result from Solr. In order to convert the result into a text file, I would recommend using one of the Solr Clients found on the Integrating Solr page in the Solr Wiki and then choose your programming language of choice to create the text file.

like image 42
Paige Cook Avatar answered Dec 20 '22 12:12

Paige Cook