0

I am new to solr. I want to load synonyms or stopwords from DB instead of txt file to solr at analyzing phase. How can I acheive it in solr 6.

I tried porting Solr-JDBC(https://github.com/shopping24/solr-jdbc), but I am unsuccessful as it uses tomcat. Can this be used with solr 6 and jetty?

starkk92
  • 5,754
  • 9
  • 43
  • 59

1 Answers1

0

Yes, you can use Solr-JDBC with Jetty, just have to configure the database connection for it. Start with naming the database connector in web.xml:

<resource-ref>
  <description>My Stopword Datasource</description>
  <res-ref-name>jdbc/stopwords</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

Then, go on with the actual configuration in jetty.xml file, a WEB-INF/jetty-env.xml file, or a context XML file:

<New id="stopwords" class="org.eclipse.jetty.plus.jndi.Resource">
  <Arg></Arg>
  <Arg>jdbc/stopwords</Arg>
  <Arg>
    <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
      <Set name="Url">jdbc:mysql://localhost:3306/databasename</Set>
      <Set name="User">user</Set>
      <Set name="Password">pass</Set>
    </New>
  </Arg>
</New>

At this point, you can use the Solr-JDBC as you would use it with a Tomcat:

<filter class="com.s24.search.solr.analysis.jdbc.JdbcStopFilterFactory"   
  sql="SELECT stopword FROM stopwords" 
  jndiName="jdbc/stopwords"/>
sven.windisch
  • 432
  • 2
  • 10