【问题标题】:Implementing SOLR PostFilter - How could I read configuration from customer post filter实施 SOLR PostFilter - 我如何从客户后过滤器中读取配置
【发布时间】:2018-06-17 01:15:56
【问题描述】:

我正在按照文章实现自定义 SOLR PostFilter 逻辑: http://qaware.blogspot.com/2014/11/how-to-write-postfilter-for-solr-49.html https://lucidworks.com/2015/05/15/custom-security-filtering-solr-5/

在我的自定义 SOLR 后过滤器中,我正在对 SQL Server 进行数据库调用,并且我需要基于环境的不同连接字符串 - dev/preprod/prod。

如何从 SOLR 中的某些配置中读取连接字符串? 是否可以以某种方式扩展配置,以便在自定义 QueryParser 中读取连接字符串?

例如,在 Solr.config 内部的某个地方定义了自定义解析器?

<queryParser name="CustomSolrPostFilter" class="CustomSolrPostFilter" />

或者以某种方式从 core.properties 文件中读取?

【问题讨论】:

    标签: solr


    【解决方案1】:

    正如通常在发布问题后发生的那样,几乎立即找到答案。

    需要在解析器声明中扩展:

    <queryParser name="CustomSolrPostFilter" class="CustomSolrPostFilter">
        <str name="myCustomConfigurationProperty">jdbc:sqlserver....</str>
    </queryParser>
    

    那么它可以在 QParserPlugin 实现中访问:

    @Override
    public void init(NamedList namedList) {
        namedList.get("myCustomConfigurationProperty") //give "jdbc:sqlserver...."
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-16
      • 2012-08-18
      • 1970-01-01
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多