我是solr的新手。我想在分析阶段从DB而不是txt文件加载同义词或停用词到solr。我如何在solr 6中获得它。
我尝试过移植Solr-JDBC(https://github.com/shopping24/solr-jdbc),但没有成功,因为它使用的是tomcat。这可以与solr 6和jetty一起使用吗?
发布于 2017-03-10 17:47:18
可以,您可以在Jetty中使用Solr-JDBC,只需为其配置数据库连接。首先在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>
然后,在jetty.xml文件、WEB-INF/jetty-env.xml文件或context XML文件中进行实际配置:
<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>
此时,您可以像使用Tomcat一样使用Solr-JDBC:
<filter class="com.s24.search.solr.analysis.jdbc.JdbcStopFilterFactory"
sql="SELECT stopword FROM stopwords"
jndiName="jdbc/stopwords"/>
https://stackoverflow.com/questions/42703906
复制相似问题