Override contextPath on solr start from command line

人盡茶涼 提交于 2019-12-08 09:45:37

问题


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"

So that the base url will be http://localhost:8983/s

To be precise, I want to override exactly contextPath property


回答1:


Your question is about the context path of solr as jetty webapp.

Instead of

http://localhost:8983/solr/ 

you want to access solr via

http://localhost:8983/s/

imho this is not possible without changing a configuration file.

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

you will get what you want:

change from

<!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>

to this:

<!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>

Now you can start with

solr start -a "-DhostContext=/s"


来源:https://stackoverflow.com/questions/34772611/override-contextpath-on-solr-start-from-command-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!