【发布时间】: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 5 时覆盖码头“contextPath”属性? 我想要类似的东西
bin/solr -p 8983 -s "example/techproducts/solr" -a "-DcontextPath=/s"
这样基本 url 将是 http://localhost:8983/s
确切地说,我想完全覆盖 contextPath 属性
【问题讨论】:
您的问题是关于 solr 作为 jetty webapp 的上下文路径。
代替
http://localhost:8983/solr/
您想通过
访问 solrhttp://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"
【讨论】: