使用 API 向 Solr 添加字段
Adding fields to Solr using the API
我是 solr 的新手。我正在尝试向架构中添加大量字段。我使用的是 8.1 版,据我了解应该通过 API.
我正在尝试使用 curl 上传所有字段,但不断出现错误。它通过网络界面运行良好。
1.我在哪里可以找到正确的字段类型?
我查过了
here,但我收到类似 "Field type 'StrField' not found" 的错误消息。
这些值也与我在网络界面中看到的值不同。
2。枚举值
我找到了documentation,这也导致未知字段错误。对于枚举,我在 Web 界面中看不到选项。
<\p>
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field":{"name":"TEST","type":"string","required":"true","stored":true,"indexed":"true"}}' http://localhost:8983/api/cores/tgec/schema
{
"responseHeader":{
"status":400,
"QTime":27},
"error":{
"metadata":[
"error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject",
"root-error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject"],
"details":[{
"add-field":{
"name":"TEST",
"type":"StrField",
"required":"true",
"stored":true,
"indexed":"true"},
"errorMessages":["Field 'TEST': Field type 'StrField' not found.\n"]}],
"msg":"error processing commands",
"code":400}}
存在名为 "string"
的字段类型,class 属于 "solr.StrField"
。
在schema.xml
中定义如下。
<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true" />
然后当你定义一个字段时,你会向它提到一个类型字符串,如下所示。
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
您需要将 "type":"StrField"
更改为 "type":"string"
。
我是 solr 的新手。我正在尝试向架构中添加大量字段。我使用的是 8.1 版,据我了解应该通过 API.
我正在尝试使用 curl 上传所有字段,但不断出现错误。它通过网络界面运行良好。
1.我在哪里可以找到正确的字段类型?
我查过了
here,但我收到类似 "Field type 'StrField' not found" 的错误消息。
这些值也与我在网络界面中看到的值不同。
2。枚举值
我找到了documentation,这也导致未知字段错误。对于枚举,我在 Web 界面中看不到选项。
<\p>
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field":{"name":"TEST","type":"string","required":"true","stored":true,"indexed":"true"}}' http://localhost:8983/api/cores/tgec/schema
{
"responseHeader":{
"status":400,
"QTime":27},
"error":{
"metadata":[
"error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject",
"root-error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject"],
"details":[{
"add-field":{
"name":"TEST",
"type":"StrField",
"required":"true",
"stored":true,
"indexed":"true"},
"errorMessages":["Field 'TEST': Field type 'StrField' not found.\n"]}],
"msg":"error processing commands",
"code":400}}
存在名为 "string"
的字段类型,class 属于 "solr.StrField"
。
在schema.xml
中定义如下。
<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true" />
然后当你定义一个字段时,你会向它提到一个类型字符串,如下所示。
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
您需要将 "type":"StrField"
更改为 "type":"string"
。