Overview
This article explain how solr can be configured to fetch data from neo4j database.Install "movie" sample database in neo4j (3.0.1)
- Click "Favourite" icon (star mark)
- Click on "Movie Graph" under "Example Graphs"
- Run the automatically generated query ":play movie-graph"
- Follow the instruction and create the database
Configuring Solr (6.0.0)
Create a core
You would need to create a core in order to be able to index and search.To create a core use following command
solr create -c <name>
i.e. solr create -c Movie -d basic_configs
Note that new folder will create as /solr-6.0.0/server/solr/Movie . And solr interface would look like below.
Import solr-dataimporthandler jars
Add following entry to /solr-6.0.0/server/solr/Movie/conf/solrconfig.xml<lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" />
Configure dataImportHandler as a requestHandler
Add following entry to /solr-6.0.0/server/solr/Movie/conf/solrconfig.xml<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">db-data-config.xml</str>
</lst>
</requestHandler>
Note: db-data-config.xml is responsible for data import handler configurations.
db-data-config.xml configurations
Create db-data-config.xml in /solr-6.0.0/server/solr/Movie/conf/ and add following content<dataSource driver="org.neo4j.jdbc.Driver" url="jdbc:neo4j://localhost:7474" user="neo4j" password="rahal" />
<document>
<entity name="movie"
query="MATCH (n:Movie) RETURN n.tagline AS tagline, n.title as title, n.released as released">
<field column="tagline" name="Tagline" />
<field column="title" name="Title" />
<field column="released" name="Released" />
</entity>
</document>
</dataConfig>
Modify the managed-schema file
Add following fields to the /solr-6.0.0/server/solr/Movie/conf/managed-schema<uniqueKey>Title</uniqueKey>
<field name="Tagline" type="string" indexed="true" stored="true"/>
<field name="Title" type="string" indexed="true" stored="true"/>
<field name="Released" type="string" indexed="true" stored="true"/>
Remove below two line segments
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<uniqueKey>id</uniqueKey>
Add Neo4j JDBC and dependencies
Get neo4j jdbc and it's dependencies using following maven config.<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-jdbc</artifactId>
<version>2.0.0-M06</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>neo4j-public</id>
<url>http://m2.neo4j.org/content/groups/public</url>
</repository>
</repositories>
You can find required dependencies using eclipse IDE and by creating a maven project using above maven config.
So following are the required jars.
- httpclient-4.3.2.jar
- httpcore-4.3.1.jar
- httpmime-4.3.jar
- jackson-core-asl-1.9.12.jar
- jackson-mapper-asl-1.9.12.jar
- neo4j-cypher-dsl-1.9.RC2.jar
- neo4j-jdbc-2.0.0-M06.jar
- org.restlet-2.2.2.jar
- org.restlet.ext.httpclient-2.2.2.jar
This blog provides many kinds of ideas, This is very helpful for my development and Thank you!!!
ReplyDeleteTableau Training in Chennai
Tableau Course in Chennai
Embedded System Course Chennai
Linux Training in Chennai
Social Media Marketing Courses in Chennai
Pega Training in Chennai
Excel Training in Chennai
Tableau Training in Chennai
Tableau Course in Chennai
Hello, I followed these steps and Solr did not fetched any documents. Could you help me out?
ReplyDelete
ReplyDeleteAmazing Post. keep update more information.
Selenium Training in Bangalore
Selenium Training in Pune
Selenium Taining in Hyderabad
Selenium Training in Gurgaon
Selenium Training in Delhi
Intersting Information... keep sharing your blog
ReplyDeleteRPA Training Institute in Chennai
Best RPA Training in Bangalore
Amazing blog...keep sharing
ReplyDeleteIELTS Training in Chennai
IELTS Classes in Chennai
IELTS Coaching in Chennai
IELTS Coaching centre in Chennai
Great post. Keep sharing such a worthy information
ReplyDeletebest java training in chennai