Home » Retrieving Data in Apache Solr

Retrieving Data in Apache Solr

by Online Tutorials Library

Retrieving Data in Apache Solr

In this tutorial page, we are going to discuss the way data will be retrieved using Java Client API. Such as, we have a .csv document that is named as sample.csv with the following data inside it.

We can now index these data under the core that is named as sample_Solr using the post command.

Given below is the Java program that is coded to add documents to Apache Solr index. Save the code inside file named as RetrievingData.java.

Compile and run the above code by executing the following commands in the terminal –

On running the above given command, we will get the following result.

{numFound = 3, start = 0, docs = [SolrDocument{id=001, phone = [+148022337],   city = [California], first_name = [Olivia],    _version_ = 1547262806014820352}, SolrDocument { id = 002, phone = [+148022338],   city = [Hawaii], first_name = [Emma],    _version_ = 1547262806026354688}, SolrDocument { id = 003, phone = [+148022339],   city = [Florida], first_name = [Sophia],    _version_ = 1547262806029500416}]} SolrDocument {id = 004, phone = [+148022337], city = [Texas], first_name = [Emily],     _version_ = 1547262806014820352}, SolrDocument { id = 002, phone = [+148022338],   city = [Hawaii], first_name = [Emma],    _version_ = 1547262806026354688}, SolrDocument { id = 003, phone = [+148022339],   city = [Florida], first_name = [Sophia],    _version_ = 1547262806029500416}  

You may also like