在 5.x 中,默认情况下,多值存储在 solr 文档中 [英] multi values are getting stored in solr document by default in 5.x
问题描述
我对 Solr 很陌生,我有一个 schema.xml 文件,我在其中定义了所有字段.但这里的问题是字段存储为多个值.我在 Solr 4.x 中尝试过同样的方法,一切都按预期工作.我在这里遗漏了什么吗?
I am quite new to Solr and I have a schema.xml file where i have defined all the fields. But the problem here is the fields are storing as multiple values. I have tried the same in Solr 4.x and everything is working as expected. Am I missing something here?
<schema name="aem-solr" version="1.5">
<field name="body" type="text_general" indexed="true" stored="true" />
<field name="description" type="text_general" indexed="true" stored="true" />
<field name="contentType" type="text_general" indexed="true" stored="true" />
<field name="lastModified" type="date" indexed="true" stored="true" />
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true" />
<field name="title" type="text_general" indexed="true" stored="true" />
<field name="url" type="text_general" indexed="true" stored="true" />
<field name="publishDate" type="tdate" indexed="true" stored="true" />
<field name="sling_resource_type" type="string" indexed="true" stored="true" multiValued="true" />
<field name="tags" type="text_general" indexed="true" stored="true" multiValued="true" />
<field name="text" type="text_general" indexed="true" stored="false" multiValued="true" />
虽然我使用的是 1.5 版架构,但所有内容都存储为多值,如下所示
Though i am using schema version 1.5 everything is storing as a multivalues as shown below
{
"id": "/content/geometrixx/en/company/bod",
"title": [
"Board of Directors"
],
"url": [
"/content/geometrixx/en/company/bod.html"
],
"lastModified": [
"2010-11-312T06:17:30Z"
],
"contentType": [
"page"
],
"tags": [
"Investor",
"Business"
],
"_version_": 1536322934890561500
}
我尝试向字段添加 multiValued= false 属性,但仍然没有运气.我正在使用 SolrJ api 在 Solr 服务器中连接和创建文档.
I tried to add multiValued= false attribute to fields but still no luck. I am using SolrJ api for connection and creating documents in Solr server.
推荐答案
这可能是由于 5.x 默认使用托管架构 - 如果正确的 schema.xml
文件不存在时您第一次启动 Solr,创建的架构将接近(如果不是)无架构模式.
This might be caused by 5.x using Managed Schema by default - if the correct schema.xml
file wasn't present when you started Solr for the first time, the created schema will be close to (if not) a Schemaless mode.
当 a 未在 solrconfig.xml 文件中显式声明时,Solr 隐式使用 ManagedIndexSchemaFactory,默认情况下它是可变的"并将架构信息保存在托管架构文件中.
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
中的ClassicIndexSchemaFactory
.如果您想改用新的托管架构工厂,该链接还包含如何让 Solr 导入旧架构的说明:
You can revert to the old behavior by changing the Schema Factory back to (or add a definition for) ClassicIndexSchemaFactory
in solrconfig.xml
. The link also contains instruction on how you can make Solr import the old schema if you want to use the new Managed Schema factory instead:
如果您现有的 Solr 集合使用ClassicIndexSchemaFactory,并且您希望转换为使用托管schema,可以简化修改solrconfig.xml来指定使用的 ManagedIndexSchemaFactory.一旦 Solr 重新启动,它检测到 schema.xml 文件存在,但managedSchemaResourceName 文件(即:managed-schema")不存在,现有的 schema.xml 文件将重命名为 schema.xml.bak 并且内容被重新写入托管架构文件.
If you have an existing Solr collection that uses ClassicIndexSchemaFactory, and you wish to convert to use a managed schema, you can simplify modify the solrconfig.xml to specify the use of the ManagedIndexSchemaFactory. Once Solr is restarted and it detects that a schema.xml file exists, but the managedSchemaResourceName file (ie: "managed-schema") does not exist, the existing schema.xml file will be renamed to schema.xml.bak and the contents are re-written to the managed schema file.
这篇关于在 5.x 中,默认情况下,多值存储在 solr 文档中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!