【问题标题】:Override contextPath on solr start from command line从命令行覆盖 solr 上的 contextPath
【发布时间】:2016-01-13 16:59:02
【问题描述】:

是否可以在使用命令行参数启动 Solr 5 时覆盖码头“contextPath”属性? 我想要类似的东西

bin/solr -p 8983 -s "example/techproducts/solr" -a "-DcontextPath=/s"

这样基本 url 将是 http://localhost:8983/s

确切地说,我想完全覆盖 contextPath 属性

【问题讨论】:

    标签: solr jetty solr5


    【解决方案1】:

    您的问题是关于 solr 作为 jetty webapp 的上下文路径。

    代替

    http://localhost:8983/solr/ 
    

    您想通过

    访问 solr
    http://localhost:8983/s/
    

    恕我直言,如果不更改配置文件,这是不可能的。

    请注意,对于 zookeeper 和 solrCloud,solr.xml 中有参数 hostContext,您可以在 solr.xml 中使用系统属性,例如 hostContext

    没有 zookeeper 但有变化

    server\contexts\solr-jetty-context.xml
    

    你会得到你想要的:

    改变

    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
      <Set name="contextPath"><Property name="hostContext" default="/solr"/></Set>
      <Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
      <Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
      <Set name="extractWAR">false</Set>
    </Configure>
    

    到这里:

    <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
    <Configure class="org.eclipse.jetty.webapp.WebAppContext">
      <Set name="contextPath"><SystemProperty name="hostContext" default="/solr"/></Set>
      <Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
      <Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
      <Set name="extractWAR">false</Set>
    </Configure>
    

    现在你可以开始了

    solr start -a "-DhostContext=/s"
    

    【讨论】:

      猜你喜欢
      • 2013-08-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 2016-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多