0

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

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

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

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

4

1 回答 1

1

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

代替

http://localhost:8983/solr/ 

您想通过以下方式访问 solr

http://localhost:8983/s/

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

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

没有动物园管理员但有变化

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"
于 2016-01-13T21:06:19.530 回答