发布
社区首页 >问答首页 >将停用词从Mysql加载到Solr6

将停用词从Mysql加载到Solr6
EN

Stack Overflow用户
提问于 2017-03-10 03:31:00
回答 1查看 49关注 0票数 0

我是solr的新手。我想在分析阶段从DB而不是txt文件加载同义词或停用词到solr。我如何在solr 6中获得它。

我尝试过移植Solr-JDBC(https://github.com/shopping24/solr-jdbc),但没有成功,因为它使用的是tomcat。这可以与solr 6和jetty一起使用吗?

EN

回答 1

Stack Overflow用户

发布于 2017-03-10 17:47:18

可以,您可以在Jetty中使用Solr-JDBC,只需为其配置数据库连接。首先在web.xml中命名数据库连接器

代码语言:javascript
代码运行次数:0
复制
<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文件中进行实际配置:

代码语言:javascript
代码运行次数:0
复制
<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:

代码语言:javascript
代码运行次数:0
复制
<filter class="com.s24.search.solr.analysis.jdbc.JdbcStopFilterFactory"   
  sql="SELECT stopword FROM stopwords" 
  jndiName="jdbc/stopwords"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42703906

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档