About us

Join us FREE!

Apache Solr exercise : learn quickly with example

Tutorial by Amit connectclue-author-image

All > Apache Solr > Apache Solr practical

1 like

Please login to like this article.

connectclue-linkedin-share

Follow below steps to start and configure solr quickly on your machine


1. Download solr from Solr Download  For window you can download the zip file of latest version and for Unix/Linux download tgz file. For example I clicked on solr-8.6.2.zip It will take user to mirror page where all files are refereed Solr Zip I clicked on Solr Zip

2. Once downloaded unzip the zip file. Make sure you have Java 8 already installed in your machine.

3. Now you can start the solr server. Solr comes with embedded Jetty server in it. So we can directly start solr server. Solr index all data in particular Collection which is also called Core. Solr provides some collection which are already created for us. We can see the present collection in the folder --solr-8.6.2\example.
Whenever we restart solr then we need to add the name of the collection.

4. Go to folder location --\solr-8.6.2\bin and run the below command to start solr with techproducts collection
  •  solr -e techproducts
 You can see in the logs that it tries to index some of the already present XML files to solr for demo/practice

 
 
 5. Once solr is started with the above message shown in screen shot then we can hit the below url to see the solr Admin UI page
 http://localhost:8983/solr/#/

 
 6. If you see the above screen shot then it means that solr is running and it's restarted successfully.
 
 7. Now click on Core Selector from left side and you can see techproducts in dropdown. Select techproducts.
 
 8. You can see all configuration for this collection techproducts.

 
 9. Click on Query tab from left panel and then click on the "Execute Query" button
 
 10. You can see the results for the data indexed in solr. You can try this query in separate browser to see the search result.
 http://localhost:8983/solr/techproducts/select?q=*%3A*
 
 
 11. For adding new item in solr, add new content in XML file under \solr-8.6.2\example\exampledocs OR create a new XML file we your new content like below.
 I have created a new file myfile.xml and added below data in that file

    


   
12. Now index this new data in solr by below command.
Go to folder example/exampledocs
and run this command. At this folder post.jsr is already present.
  •  java -Dc=techproducts -jar post.jar myfile.xml






13. Now search for the new content which you have just indexed as http://localhost:8983/solr/techproducts/select?q=mymenu



14. You can shut down solr. Go to folder location --\solr-8.6.2\bin and run the below command
  •  solr stop
 

Stay tuned for more updated and more exercise with steps and example.


Happy learning!!





Login for enhanced experience

connectclue-tick Create and manage your profile

connectclue-tick Refer an author and get bonus Learn more

connectclue-tick Publish any lost and found belongings

connectclue-tick Connect with the authors & add your review comments

connectclue-tick Join us for Free to advertise for your business or Contact-us for more details

connectclue-tick Join us for Free to publish your own blogs, articles or tutorials and get your Benefits

connectclue-login

Back to top