Solr is an Open-Source Search Platform built on Lucene which makes searching fairly easy. In this tutorial we will see how we can Index documents in SOLR. Indexing means adding content to the SOLR index which can be easily searchable.
PC : Wikipedia
The advantage of using SOLR is that, it can accept the data from any sources be it JSON file, XML or even database. Whatever be the source of data, one thing is common among them is how to fed the data to the SOLR which is nothing but as a document. A document contains multiple fields having name and content.
Since I mainly work with Rational Database, I use DataImportHandler for getting the data out of the database. The main steps to follow while indexing the documents are
- Read the data
- Create SOLR documents
- Differentiate between Full and Partial Update (Inserting and Updating).
DataImportHandler
Now the next step is to configure the DataImportHandler in the SOLRConfig.xml file and you need to provide the location of data-config file which has the code to fetch the data, read the data and process the data to create SOLR document.
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">pathtoconfigfile.xml</str>
</lst>
</requestHandler>
The Sample Data-Config File looks like below :
<dataConfig>
<dataSource driver="org.hsqldb.jdbcDriver" url="URL of Data Source" user="sa" />
<document>
<entity>
//the entity which you would like to import
</entity>
</document>
</dataConfig>
The commands used by DataImportHandler are :
- Abort - To abort indexing the documents.
- Full-Import - It will import all the documents from the database. Note that querying is not blocked while full-import is going on. Full import usually takes some time depending on the number of documents.
- Delta-Import - It imports only the new documents or any changes happened to the previous documents.
- Status - Shows the number of documents created, updated or deleted.
Posted on Utopian.io - Rewarding Open Source Contributors
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Found your post interesting to read. I can't wait to see your post soon. Good Luck with the upcoming update.This article is really very interesting and effective. @codingdefined
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
How did you become a moderator for Utopian? I'm interested but don't know how to start.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
You can contact on Utopian Discord, if there is a slot empty you can be the one.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @codingdefined I am @utopian-io. I have just upvoted you!
Achievements
Suggestions
Get Noticed!
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit