从命令行开始在Solr上覆盖contextPath [英] Override contextPath on solr start from command line
问题描述
使用命令行参数启动Solr 5时是否可以覆盖码头的"contextPath"属性? 我想要类似的东西
Is it possible to override jetty "contextPath" property when starting Solr 5 using command line arguments? I want something like
bin/solr -p 8983 -s "example/techproducts/solr" -a "-DcontextPath=/s"
这样基本网址将是 http://localhost:8983/s
确切地说,我想完全覆盖contextPath属性
To be precise, I want to override exactly contextPath property
推荐答案
您的问题是关于Solr作为码头Web应用程序的上下文路径.
Your question is about the context path of solr as jetty webapp.
代替
http://localhost:8983/solr/
您要通过
http://localhost:8983/s/
恕我直言,这不可能不更改配置文件.
imho this is not possible without changing a configuration file.
请注意,对于Zookeeper和solrCloud,有一个参数 hostContext 在 solr.xml ,您可以在solr.xml中使用系统属性,例如 hostContext .
Be aware that with zookeeper and solrCloud there is the parameter hostContext in solr.xml and you can use system properties in solr.xml like hostContext.
没有动物园管理员但有变化
Without zookeeper but with changing
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"
这篇关于从命令行开始在Solr上覆盖contextPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!