We need to update the default Solr configuration to work with our data. We also need to upload some initial data into the Solr index before the Rails app and Passenger will display the Blacklight app interface on the screen.
1. Using Terminal, connect to the VPS as the root user:
2. Change directories into the solr directory:
3. In a web browser, check to see if Solr is already running by going to
If it is, skip the following start up step. If it is not running, start the Solr service with the following command in Terminal:
4. Create a Solr core for the Blacklight data using the basic_configs instead of the default data_driven_schema_configs (these can be found at solr-5.3.0/server/solr/configsets and are copied in during the core creation):
5. The new core should now have a directory at
6. Refresh the Solr admin UI in the web browser to confirm the new core is created and accessible.
7. The blacklight-core collection in Solr is currently using the default scheme found at
The Blacklight interface is not set up to use this schema. Edits to both the Blacklight settings and the Solr schema will be necessary.
8. Download the schema.xml file using a FTP program and open it in a text editor.
9. I explicitly defined a number of fields by adding the lines such as the following below the <field name=“id” … /> line:
As the fields above indicate, some of the fields I defined were multivalued="true" and some were multivalued="false". This depended on whether the field would be used as a sort field because it appears sort fields can only be multivalued="false".
Create as many field names as you need to fill out your schema.
10. Go down in the schema.xml file below the <uniqueKey> line and add the following copyFields:
This copies the value of the source field into an additional field "as is" instead of being reformatted as part of the indexing process. This is necessary for the Facet options to show up correctly, so do this for any fields you plan to use as facets.
11. Save the schema.xml file and use the FTP program to replace the copy on the server with the copy you just edited.
12. In terminal, restart the solar service with the following two commands:
13. Use the FTP program to upload your data document (we'll call it "data.json") to be indexed to the folder
14. Index the data document into the Solr index by running the following Terminal command:
15. Refresh the Solr Admin UI in the web browser to confirm the document was indexed (there should be many more docs in the index now)
Errors will still appear on the Blacklight interface because Blacklight’s CatalogController is looking for certain fields that are not in the schema.
Previous post: Determine Ruby command for Passenger and update configuration files
Next post: Update Blacklight's catalog_controller file
Creating the new Solr core
1. Using Terminal, connect to the VPS as the root user:
$ ssh root@example.com
2. Change directories into the solr directory:
# cd /home/username/solr/solr-5.3.0
3. In a web browser, check to see if Solr is already running by going to
example.com:8983
If it is, skip the following start up step. If it is not running, start the Solr service with the following command in Terminal:
# bin/solr start -noprompt
4. Create a Solr core for the Blacklight data using the basic_configs instead of the default data_driven_schema_configs (these can be found at solr-5.3.0/server/solr/configsets and are copied in during the core creation):
# bin/solr create -c blacklight-core -d basic_configs
5. The new core should now have a directory at
/home/username/solr/solr-5.3.0/server/solr/blacklight-core
6. Refresh the Solr admin UI in the web browser to confirm the new core is created and accessible.
Updating the default Solr schema
7. The blacklight-core collection in Solr is currently using the default scheme found at
/home/username/solr/solr-5.3.0/server/solr/blacklight-core/conf/schema.xml
The Blacklight interface is not set up to use this schema. Edits to both the Blacklight settings and the Solr schema will be necessary.
8. Download the schema.xml file using a FTP program and open it in a text editor.
9. I explicitly defined a number of fields by adding the lines such as the following below the <field name=“id” … /> line:
<field name="field1_txt" type="text_general" indexed="true" stored="true" multiValued="true"/>
<field name="field1Facet" type="string" indexed="true" stored="false" multiValued="true"/>
<field name="field2_txt" type="text_general" indexed="true" stored="true" multiValued="false"/>
As the fields above indicate, some of the fields I defined were multivalued="true" and some were multivalued="false". This depended on whether the field would be used as a sort field because it appears sort fields can only be multivalued="false".
Create as many field names as you need to fill out your schema.
10. Go down in the schema.xml file below the <uniqueKey> line and add the following copyFields:
<copyField source="field1_txt" dest="field1Facet"/>
This copies the value of the source field into an additional field "as is" instead of being reformatted as part of the indexing process. This is necessary for the Facet options to show up correctly, so do this for any fields you plan to use as facets.
11. Save the schema.xml file and use the FTP program to replace the copy on the server with the copy you just edited.
12. In terminal, restart the solar service with the following two commands:
$ bin/solr stop -all
$ bin/solr restart
13. Use the FTP program to upload your data document (we'll call it "data.json") to be indexed to the folder
/home/username/solr/solr-5.3.0/
14. Index the data document into the Solr index by running the following Terminal command:
$ bin/post -c blacklight-core data.json
15. Refresh the Solr Admin UI in the web browser to confirm the document was indexed (there should be many more docs in the index now)
Errors will still appear on the Blacklight interface because Blacklight’s CatalogController is looking for certain fields that are not in the schema.
Previous post: Determine Ruby command for Passenger and update configuration files
Next post: Update Blacklight's catalog_controller file
Excellent post ruby on rails Update Solr schema configuration . Very interesting to read. I really love to read such a nice post. Thanks! keep rocking. get more info on Ruby on Rails Online Training Hyderabad
ReplyDeleteReally Good blog post. provided a helpful information. I hope that you will post more updates like this Ruby on Rails Online Training Bangalore
ReplyDelete