Solrj 将类型从 long 更改为 string
Solrj change type from long to string
我在 Solrj 中查询时遇到问题。我创建了文档,其中每个文档都有 String 字段和 Long 字段。
例如:
各种:PLZ - 类型:字符串
doc.addField("plz",tmp.getPlz());
我将其添加到每个文档中,但 Solr 将其保存为 long。为什么?我该如何改变它? Ps。 PLZ in 永远是一个数字,比如 6868
你 define the field type for each field name in the schema for your collection or core. You do this in the same way 关于架构。
如果你想告诉 Solr 对特定字段使用特定类型,首先你必须定义类型(在 schema.xml
中的 <types> .. </types>
内):
<fieldType name="string" class="solr.StrField" />
然后在字段定义中使用该类型:
<field name="description" type="string" indexed="false" stored="true" />
.. 根据需要调整 indexed
/stored
属性。
如果您想要一个长字段,请将字段定义为对您的 Solr 版本有效的 long/integer 类型。
我在 Solrj 中查询时遇到问题。我创建了文档,其中每个文档都有 String 字段和 Long 字段。
例如:
各种:PLZ - 类型:字符串
doc.addField("plz",tmp.getPlz());
我将其添加到每个文档中,但 Solr 将其保存为 long。为什么?我该如何改变它? Ps。 PLZ in 永远是一个数字,比如 6868
你 define the field type for each field name in the schema for your collection or core. You do this in the same way
如果你想告诉 Solr 对特定字段使用特定类型,首先你必须定义类型(在 schema.xml
中的 <types> .. </types>
内):
<fieldType name="string" class="solr.StrField" />
然后在字段定义中使用该类型:
<field name="description" type="string" indexed="false" stored="true" />
.. 根据需要调整 indexed
/stored
属性。
如果您想要一个长字段,请将字段定义为对您的 Solr 版本有效的 long/integer 类型。