简体   繁体   English

solr使用脚本启用托管模式

[英]solr enable managed schema with script

I need to change the schema from .xml to managed schema on several solr servers, unfortunately it has to be done with some sort of groovy script (can do curls) that will run once automatically when it gets deployed. 我需要将多个solr服务器上的模式从.xml更改为托管模式,不幸的是,它必须使用某种常规脚本(可以执行curl)来完成,该脚本在部署后会自动运行一次。 This is because of our deployment strategy we can't modify the files on the servers. 这是由于我们的部署策略,我们无法修改服务器上的文件。 A colleague told me this was possible, but I have read about the managed schema API and now I am wondering if that's even possible, because there was not mentioned anything about such a feature. 一位同事告诉我这是有可能的,但是我已经阅读了有关托管模式API的信息,现在我想知道这是否有可能,因为没有提及任何有关此功能的信息。

Changing between the Classic Scheme and the Managed Scheme is a setting in the configuration file for your Solr instances, and is not something you can change through the web interface as far as I know. 在经典方案和托管方案之间进行更改是Solr实例的配置文件中的一项设置,据我所知,您不能通过Web界面进行更改。

See Schema Factory Definition in SolrConfig : 请参阅SolrConfig中的架构工厂定义

When a is not explicitly declared in a solrconfig.xml file, Solr implicitly uses a ManagedIndexSchemaFactory, which is by default "mutable" and keeps schema information in a managed-schema file. 当未在solrconfig.xml文件中明确声明a时,Solr隐式使用ManagedIndexSchemaFactory,默认情况下它是“可变的”,并将模式信息保留在托管模式文件中。

<!-- An example of Solr's implicit default behavior if no
     no schemaFactory is explicitly defined.
-->
<schemaFactory class="ManagedIndexSchemaFactory">
   <bool name="mutable">true</bool>
   <str name="managedSchemaResourceName">managed-schema</str>
 </schemaFactory>

This assumes you're using a recent enough version of Solr that actually provides support for the Schema API and using the managed schema. 假设您使用的是最新版本的Solr,该版本实际上提供了对Schema API的支持并使用了托管模式。

If your servers are configured to use the managed schema, adding fields and changing the schema definition is doable through the API with cURL or other HTTP libraries. 如果您的服务器配置为使用托管模式,添加字段和更改模式定义是通过与卷曲或其他HTTP库的API是可行的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM