• Articles
  • Tutorials
  • Interview Questions

Solr Indexing and Querying for Absolute Beginners

Solr Indexing

Indexing is the process of pushing the XML files into SOLR index, this process is also known as feeding. The other methods to get the data into SOLR are as below.

  • Data import handler (DIH): it is a powerful language permits you to read from a SQL database, XML files, CSV, etc. the full- imports and the data imports will be handled by DIH. DIH is more convenient if a small amount of data were added, modernized and removed.
  • HTTP interface: this method will be used for indexing the XML files. HTTP interface taken from the post tool.
  • Client libraries: the client libraries have existed in different languages. For example: Java or python.

pic2

Solr Querying

It is efficient to use the HTTP interface for debugging, with any browser to query in SOLR and get back XML. The default query parser of the SOLR is known as Lucene parser.

The standard query parser parameters

Along with the Faceting parameters, common query parameters, highlighting parameters the standard query parser also supports parameters as described in the below table.

Parameters Description
q This parameter is mandatory, helps in defining the query using standard query syntax
q.op These parameters specify the default operator for query expressions, overrides the default operator as present in the schema. AND and OR are the possible values.
df This recognizes the default field, overriding the default field in the schema.

Example for responses from the Standard Query Parser

The below given URL will submit a simple query and send requests to the XML response writer to use indentation to create the XML response more readable.

http://localhost:8983/solr/softproducts/select?q=id:SP2514N

Results:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<responseHeader><status>0</status><QTime>1</QTime></responseHeader>
<result numFound="1" start="0">
 <doc>
  <arr name="cat"><str>Industry</str><str>Software </str></arr>
  <arr name="characteristics"><str>coded in Java</str>
    <str>Microsoft products, Snake-ladder gaming </str></arr>
  <str name="id">Int456</str>
  <bool name="inStock">true</bool>
  <str name="manu">Intellipaat software Solutions </str>
  <int name="popularity">6</int>
  <float name="price">100.00</float>
  <str name="sku">Int789</str>
 </doc>
</result>
</response>

Certification in Bigdata Analytics

Example for query with the limited field lists
http://localhost:8983/solr/softproducts/select?q=id:SP2514N&fl=id
Results:

<?xml version="1.0" encoding="UTF-8"?>
<response>
<responseHeader><status>0</status><QTime>2</QTime></responseHeader>
<result numFound="1" start="0">
 <doc>
  <str name="id">Int456</str>
   </doc>
</result>
</response>

 

Course Schedule

Name Date Details
Big Data Course 14 Dec 2024(Sat-Sun) Weekend Batch View Details
21 Dec 2024(Sat-Sun) Weekend Batch
28 Dec 2024(Sat-Sun) Weekend Batch

About the Author

Technical Research Analyst - Big Data Engineering

Abhijit is a Technical Research Analyst specialising in Big Data and Azure Data Engineering. He has 4+ years of experience in the Big data domain and provides consultancy services to several Fortune 500 companies. His expertise includes breaking down highly technical concepts into easy-to-understand content.