{"id":20915,"date":"2015-06-15T12:29:39","date_gmt":"2015-06-15T06:59:39","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=20915"},"modified":"2017-03-22T15:58:03","modified_gmt":"2017-03-22T10:28:03","slug":"apache-solr-5-1-0","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/apache-solr-5-1-0\/","title":{"rendered":"Apache Solr 5.1.0"},"content":{"rendered":"<p>Apache Solr is an open source search platform built upon a Java library called Lucene.<\/p>\n<p>Solr is a popular search platform for Web sites because it can index and search multiple sites and return recommendations for related content based on the search query\u2019s taxonomy. Solr is also a popular search platform for enterprise search because it can be used to index and search documents and email attachments.<\/p>\n<p>Solr works with Hypertext Transfer Protocol (HTTP) Extensible Markup Language (XML). It offers application program interfaces (APIs) for Javascript Object Notation (JSON), Python, and Ruby. According to the Apache Lucene Project, Solr offers capabilities that have made it popular with administrators including:<\/p>\n<p>Advanced Full-Text Search Capabilities<br \/>\nOptimized for High Volume Web Traffic<br \/>\nStandards Based Open Interfaces &#8211; XML, JSON and HTTP<br \/>\nComprehensive HTML Administration Interfaces<br \/>\nServer statistics exposed over JMX for monitoring<br \/>\nLinearly scalable, auto index replication, auto failover and recovery<br \/>\nNear Real-time indexing<br \/>\nFlexible and Adaptable with XML configuration<br \/>\nExtensible Plugin Architecture<\/p>\n<p><strong>Overview<\/strong><\/p>\n<p>In this blog of Apache Solr ,we will show you how to install the latest version of Apache Solr 5.1.0 configuration and perform the index using a data file. Apache Solr supports indexing from different source formats including various databases, PDF files, XML files, CSV files etc.<\/p>\n<p>We will look how to index basic data from a CSV file by using apache solr.<\/p>\n<p>There is recent changes in directory structure of solr from previous versions solr 4.x for reference follow link.<\/p>\n<p>[js]https:\/\/lucene.apache.org\/solr\/5_0_0\/changes\/Changes.html#v5.0.0.upgrading_from_solr_4.x[\/js]<\/p>\n<p>Download the Apache solr latest version from below link on your system:<\/p>\n<p>[js]wget http:\/\/apache.mirrors.ionfish.org\/lucene\/solr\/5.1.0\/solr-5.1.0.zip[\/js]<\/p>\n<p>[js]unzip\u00a0solr-5.1.0.zip[\/js]<\/p>\n<p>[js]cd\u00a0solr-5.1.0[\/js]<\/p>\n<p>Apache solr directory Structure Overview:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20988\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot_.png\" alt=\"Screenshot_\" width=\"148\" height=\"185\" \/><\/p>\n<p><b>Start Solr<\/b><\/p>\n<p>[js]bin\/solr start -p 8983[\/js]<\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong>-p specifies port number (by default port number 8983)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20990\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-114404.png\" alt=\"Screenshot from 2015-06-15 11:44:04\" width=\"587\" height=\"350\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><b>Core Creation<\/b><\/p>\n<p>When the Solr server is started in Standalone mode the configuration is called core and when it is started in SolrCloud mode the configuration is called Collection. In this we will discuss about the standalone server and core.<\/p>\n<p>SolrCloud Collection mode<\/p>\n<p>solr create_collection [-c collection] [-d confdir] [-n configName] [-shards #] [-replicationFactor #] [-p port]<\/p>\n<p><b>Standalone Mode<\/b><\/p>\n<p>solr create_core [-c core] [-d confdir] [-p port]<\/p>\n<p>[js]bin\/solr create_core -c power1 -d sample_techproducts_configs -p 8983[\/js]<\/p>\n<p>This will create core power1 for solr running on port 8983 with example configuration with many optional features enabled to demonstrate the full power of Solr.<\/p>\n<p>Now all your cores created &lt;ApacheSolr_Home&gt;\/server\/solr\/ folder.(like i have created power1)<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20991\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-114518.png\" alt=\"Screenshot from 2015-06-15 11:45:18\" width=\"132\" height=\"118\" \/><\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong>As you see in below screenshot Core power1 has been created when you select the Core Selector.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20992\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-114606.png\" alt=\"Screenshot from 2015-06-15 11:46:06\" width=\"557\" height=\"342\" \/><\/p>\n<p>Core Power1 Directory structure<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20993\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-114820.png\" alt=\"Screenshot from 2015-06-15 11:48:20\" width=\"599\" height=\"539\" \/><\/p>\n<p><b>Create the Sample CSV File to index and save it as testing.csv<\/b><\/p>\n<p>Content of testing.csv<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20994\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-114959.png\" alt=\"Screenshot from 2015-06-15 11:49:59\" width=\"1195\" height=\"173\" \/><\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong><\/p>\n<p>[js]cat,_version_,price_c,series_t,id,author,rank,price,sequence_i,name,author_s,inStock,genre_s<br \/>\nbook,1503669092110827520,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;7.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,A Song of Ice and Fire,0553573403,George R.R. Martin,1.2,7.99,1,A Game of Thrones,George R.R. Martin,true,fantasy<br \/>\nbook,1503669092137041920,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;7.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,A Song of Ice and Fire,0553579908,George R.R. Martin,2.3,7.99,2,A Clash of Kings,George R.R. Martin,true,fantasy<br \/>\nbook,1503667880901738496,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;17.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,Foundation Novels,0553293354,Isaac Asimov,,17.99,1,Adobe_ttn,Isaac Asimov,true,scifi<br \/>\nbook,1503667880903835648,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;6.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,the Chronicles of Amber,0380014300,Roger Zelazny,,6.99,1,Nine Princes In Amber,Roger Zelazny,true,fantasy<br \/>\nbook,1503667880904884224,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;5.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,The Chronicles of Prydain,080508049X,Lloyd Alexander,,5.99,2,The Black Cauldron,Lloyd Alexander,true,fantasy<br \/>\nbook,1503667880905932800,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;15.03\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,The Chronicles of Prydain,080508056X,Ankit,,15.03,2,The Black Cauldron,Ankit,true,fantasy<br \/>\nbook,1503667880906981376,&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;16.99\\,USD&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;,snapper,0812550706,Orson Scott Card,,16.99,1,snapper_ttn,Orson Scott Card,true,scifi[\/js]<\/p>\n<p><b>Schema.xml<\/b><\/p>\n<p>It is usually the first file you configure when setting up a new Solr installation.<\/p>\n<p>The schema declares:<\/p>\n<ul>\n<li>what kinds of fields there are<\/li>\n<li>which field should be used as the unique\/primary key<\/li>\n<li>which fields are required<\/li>\n<li>how to index and search each field<\/li>\n<\/ul>\n<p>Now we need to make change in schema.xml (server\\solr\\power1\\conf) which provide by default by solr while using the sample_techproducts_configs (Example configuration with many optional features enabled to demonstrate the full power of Solr) as per the our content in file testing.csv put on solr for indexing.We define the field which we are going to use in our testing.csv.<\/p>\n<p>Edit the schema.xml file in the \\server\\solr\\power1\\conf folder and add the following contents after the uniqueKey element.<\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong>&lt;field name=&#8221;name&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;cat&#8221; type=&#8221;string&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221; multiValued=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;price&#8221; \u00a0type=&#8221;float&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;inStock&#8221; type=&#8221;boolean&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221; \/&gt;<\/p>\n<p>&lt;field name=&#8221;store&#8221; type=&#8221;location&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;rank&#8221; type=&#8221;float&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;title&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221; multiValued=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;subject&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;author&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;keywords&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;category&#8221; type=&#8221;text_general&#8221; indexed=&#8221;true&#8221; stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;dynamicField name=&#8221;*_t&#8221; \u00a0type=&#8221;text_general&#8221; \u00a0\u00a0\u00a0indexed=&#8221;true&#8221; \u00a0stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>&lt;dynamicField name=&#8221;*_s&#8221; \u00a0type=&#8221;text_general&#8221; \u00a0\u00a0\u00a0indexed=&#8221;true&#8221; \u00a0stored=&#8221;true&#8221;\/&gt;<\/p>\n<p>Note: As \u00a0we are using sample_techproducts_configs so field name and dynamic Field already present in schema.xml we need to check it before adding line in schema.xml.<\/p>\n<p>Repetition will throw error at the time of indexing.<\/p>\n<p>Attribute indexed to true. This specifies the field is used for indexing and the record can be retrieved using the index. Setting the value to false will make the field only stored but can\u2019t be queried with.Another attribute called stored and set it to true. This specifies the field is stored and can be returned in the output. Setting this field to false will make the field only indexed and can\u2019t be retrieved in output.<\/p>\n<p><strong><strong>\u00a0<\/strong><\/strong>For Indexing in solr please reference the below link<\/p>\n<p>[js]http:\/\/www.solrtutorial.com\/basic-solr-concepts.html[\/js]<\/p>\n<p>After changes in schema.xml restart the solr<\/p>\n<p>[js]bin\/solr restart -p 8983[\/js]<\/p>\n<p><b>Indexing the content<\/b><\/p>\n<p>Solr includes a simple command line tool for POSTing various types of content to a Solr server. The tool is bin\/post. The bin\/post tool is a Unix shell script<\/p>\n<p>[js]bin\/post -c power1 testing.csv -p 8983[\/js]<\/p>\n<p>bin\/post -c core_name &lt;file_name_to_index&gt; -p &lt;Port_number&gt;<\/p>\n<p>For more details use bin\/post -help<\/p>\n<p><strong>Search Indexed File<\/strong><\/p>\n<p>Search the indexed by using the schema browser option available on apache solr dashboard.<\/p>\n<p>Select the required field name for result.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20995\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-115057.png\" alt=\"Screenshot from 2015-06-15 11:50:57\" width=\"635\" height=\"335\" \/><\/p>\n<p>We selected the author field to fetch the required details from solr<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20996\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-115231.png\" alt=\"Screenshot from 2015-06-15 11:52:31\" width=\"632\" height=\"349\" \/><\/p>\n<p>Select required author available in author field name to get the details<\/p>\n<p>i.e we have selected author ankit to get respective details<\/p>\n<p><strong><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-20997\" src=\"\/blog\/wp-ttn-blog\/uploads\/2015\/06\/Screenshot-from-2015-06-15-115326.png\" alt=\"Screenshot from 2015-06-15 11:53:26\" width=\"629\" height=\"347\" \/>\u00a0<\/strong><\/strong><\/p>\n<p>We have option available to view data in different format json,xml,csv etc.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache Solr is an open source search platform built upon a Java library called Lucene. Solr is a popular search platform for Web sites because it can index and search multiple sites and return recommendations for related content based on the search query\u2019s taxonomy. Solr is also a popular search platform for enterprise search because [&hellip;]<\/p>\n","protected":false},"author":215,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[1174],"tags":[1874,1873,1875,1876],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20915"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/215"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=20915"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/20915\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=20915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=20915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=20915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}