Professional Documents
Culture Documents
What is Solr
Solr is pronounced as Solar. It stands for Searching on Lucene . Web-based Indexing & Searching Server By default, comes bundled with Jetty server Can also be deployed in any other servlet container like Tomcat, Resin etc.
Advantages of Solr
Solr can replicate index on multiple servers. Uses REST based web-services for indexing and searching Indexing and search can be done simultaneously. Supports faceted searching. Supports result clustering. Supports Hit highlighting Supports Multiple output formats (XML/XSLT and JSON).
Deploying Solr
Following are the steps for deploying Solr in Jetty:
Download Solr and install it. Root directory of Solr [eg: D:\tools\solr] is referred as SOLR_HOME.
Start Solr services. To start the service, execute start.jar present in SOLR_HOME/example/. java jar start.jar
Default port for jetty is 8983.Once the service is started, type in URL
http://localhost:8983/solr Solr admin screen appears.
schema.xml - Describes the data type Field type Analyzer and Tokenizer used on fields Copy fields Default Field
Solr Indexing
In Java project, use solrj API for indexing Initialize SolrServer. Create document Insert fields into document. Add the documents to server. Commit the server.
Insert fields into document SolrInputDocument doc1 = new SolrInputDocument(); doc1.addField ("employeeid", "1234");
Add the documents to server _server. add (doc1); Server commit _server. commit (); Executing the application Before running the application, ensure the solar service has started. Execute the application. View in Solr by running Queries http://localhost:8983/solr Output, by default, is visible in XML format.
Solr Search
One option to search over the solr index is using SolrJ. For this, the user needs to define the server, create query object, and send the query to the server to fetch response. SolrServer _server = new CommonsHttpSolrServer ("http://localhost:8983/solr"); SolrQuery solrquery = new SolrQuery (); solrquery.setQuery (<enter query here>); QueryResponse rsp = _server.query (solrquery); In Solr, the search queries are processed by the appropriate SolrRequestHandler. Range, Prefix, Boolean, Wildcard queries are allowed in Solr.
Why Solr
Replication of Index Scalable and Fault Tolerant (Depending upon the underlying infrastructure) Built in Faceted Search Capabaility
SCREENSHOTS
Resources
http://lucene.apache.org http://lucene.apache.org/solr
http://minion.dev.java.net/
Thank You