Spring
- Download Spring Tool Suite from https://spring.io/tools/sts/all
- Install Apahce Maven
- Import project in STS
- Run as a Spring Boot App
Solr
- Download and install Java 8+ if not done already
- Download apache solr 7.3.1
- Unpack downloaded zip
- Navigate to bin folder
- Run
solr start
- Run
solr create -c <core-name>
. This will create a folder in your solr directory\server\solr\<core-name>
- Create a folder in the root solr directory to store necessary .jar files. ie)
.\jarfiles
- In directory
./dist
copysolr-dataimporthandler-7.3.1.jar
andsolr-dataimporthandler-extras-7.3.1.jar
and paste in previously created directory. - Download mySQL Connector/J from https://dev.mysql.com/downloads/connector/j/5.1.html
- Copy and paste the extracted
*-bin.jar
file in the previously created directory. - Navigate to
\server\solr\<core-name>\conf\solrconfig.xml
and addand<lib dir="../../../jarfiles" regex=".*\.jar" />
within the<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">db-data-config.xml</str> </lst> </requestHandler>
<config>
tag - Create a
db-data-config.xml
file in./conf
and paste with correct, password, etc..<dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/skill_tracker" user="root" password="*************" /> <document> <entity name="employee" query="SELECT ID, FN, LN, DOB, DOJ, CL, ADDRESS, CITY, STATE, ZIPCODE, CREATED, UPDATED FROM employee"> <field column="ID" name="Id" /> <field column="FN" name="firstName" /> <field column="LN" name="lastName" /> <field column="DOB" name="dateOfBirth" /> <field column="DOJ" name="dateOfJoin" /> <field column="CL" name="careerLevel" /> <field column="ADDRESS" name="address" /> <field column="CITY" name="city" /> <field column="STATE" name="state" /> <field column="ZIPCODE" name="zipcode" /> <field column="CREATED" name="created" /> <field column="UPDATED" name="updated" /> <entity name="skill" pk="SKILLID" query="SELECT * FROM skill WHERE ID='${employee.ID}'"> <field column="SKILL" name="skills" /> </entity> </entity> </document> </dataConfig>
- In
./managed-schema
add field tags with correct fields<field name="Id" type="text_general" indexed="true" stored="true" required="true" multiValued="false"/> <field name="firstName" type="text_general" indexed="true" stored="true"/> <field name="lastName" type="text_general" indexed="true" stored="true" /> <field name="dateOfBirth" type="text_general" indexed="true" stored="true"/> <field name="dateOfJoin" type="text_general" indexed="true" stored="true"/> <field name="careerLevel" type="text_general" indexed="true" stored="true"/> <field name="address" type="text_general" indexed="true" stored="true"/> <field name="city" type="text_general" indexed="true" stored="true"/> <field name="state" type="text_general" indexed="true" stored="true"/> <field name="zipcode" type="text_general" indexed="true" stored="true"/> <field name="created" type="text_general" indexed="true" stored="true" multiValued="false"/> <field name="updated" type="text_general" indexed="true" stored="true"/> <field name="skills" type="string" indexed="true" stored="true" multiValued="true"/> <fieldType name="word_concate" class="solr.TextField" indexed="true" stored="false"> <analyzer> <charFilter class="solr.PatternReplaceCharFilterFactory" pattern="\s*" replacement=""/> <tokenizer class="solr.StandardTokenizerFactory"/> </analyzer> </fieldType> <field name="cfname" type="word_concate"/> <copyField source="careerLevel" dest="cfname"/> <field name="skillsNoSpaces" type="word_concate" multiValued="true"/> <copyField source="skills" dest="skillsNoSpaces"/>
- Open browser, and go to http://localhost:8983/solr/#/
- To stop solr, run
solr stop -all
- To restart solr, run
solr start