Apache Solr is an open source search server. It includes the full-text search engine called Apache Lucene. So basically Solr is an HTTP wrapper around an inverted Index provided by Lucene. The purpose of Inverted Index is to allow the fast full-text search, at a cost of increased processing when a document is added to the database. The inverted file may be the database file itself, rather than its index. It is the most popular data structure used in retrieving the document systems, used on a large scale like in Search Engine.
Now you have a little bit of idea what Apache Solr does now lets download and start working on it. You can download the latest version from here.
It’s easy to install and start ApacheSolr. just follow these steps and we are good to go.
- Download Apache Solr from here.
- Extract to the desired location
- Change directory to Apache Solr.
- type ./bin/solr start -e cloud -noprompt
- To stop Apache Solr type ./bin/solr stop -all
If you started the Apache Solr then you can go to http://localhost:8983/solr/ you will see Solr Admin panel. if you wish to change the port from 8983 to something else you can do this while starting Solr with -p option like ./bin/solr start -p 4444 . when you start Apache Solr for the first time there will be not data to play or query on you need to feed some data to Apache Solr by the following command ./bin/post -c gettingstarted examples/exampledocs/*.xlm these are example XML document that getting ingested to Solr.
Now let’s see some options to start ApacheSolr with:-
- -a for adding JVM Options like
bin/solr start -a "-Xdebug -Xrunjdwp:transport=dt_socket, server=y,suspend=n,address=1044"
- -c Start Solr in SolrCloud mode, which will also launch the embedded ZooKeeper instance included with Solr.
- -d for defining server directory.
- -e for example configuration like
- -f for running in the foreground.
- -noprompt Start Solr and suppress any prompts that may be seen with another option. This would have the side effect of accepting all defaults implicitly.
These are most useful options to start Apache Solr with you can find more options here.
After you installed and started the Apache Solr then you can add some data. For inserting Data you can use post command like this
bin/post -c collection_name path_to_data
Default collection is gettingstarted you can also create you own collection by this command bin/solr start -e cloud then follow the steps as needed.
Now you have Solr ready and Data Inserted you can now play around with Querying data from UI at localhost:8983/solr then select the collection from collection list and click on query section. You can find more details about Query here.