简体   繁体   English

在 solr 架构中添加字段。xml

[英]Add field in solr schema.xml

I am using solr to make search on my database, and am trying to add a new field (publisher_id of an article) in conf/schema.xml to get the value of the publisher_id after making search on my database, i didn't find any field name equivalent to this field.我正在使用 solr 对我的数据库进行搜索,并尝试在 conf/schema.xml 中添加一个新字段(文章的publisher_id)以在对我的数据库进行搜索后获取publisher_id 的值,我没有找到任何与此字段等效的字段名称。 so how can i add it as a field in schema.xml to be returned with the searched values (body,title,date and publisher_id) of the article?那么如何将其添加为 schema.xml 中的字段以与文章的搜索值(正文、标题、日期和发布者 ID)一起返回?

First of all: what kind of data is stored in publisher_id?首先:publisher_id 中存储了什么样的数据? If it is a number (int, log) so add an field with the corresponding type, like:如果它是一个数字(int,log),那么添加一个具有相应类型的字段,例如:

<field name="publisher_id" type="int" indexed="true" stored="true" />

After adding a field to the schema.xml, you have to restart the solr-instance and rebuild your index.将字段添加到 schema.xml 后,您必须重新启动 solr-instance 并重建索引。

Note that dynamic field additions have been added in Solr 4.4 and Solr 5.0 ...neither of which are yet released.请注意,在 Solr 4.4 和 Solr 5.0 中添加了动态字段...两者都尚未发布。

In the meantime, if you wish to add a field to your index, you have two options.同时,如果您希望将字段添加到索引中,您有两个选择。 First, you can do the hard way: Add the field to your schema, clear your index, restart Solr and reindex everything.首先,您可以采取艰难的方式:将字段添加到架构中,清除索引,重新启动 Solr 并重新索引所有内容。 This tends to be a bit untenable.这往往有点站不住脚。

Alternatively, you can use a dynamic field declaration .或者,您可以使用动态字段声明 If you look in the schema, you'll see lines like these:如果您查看架构,您会看到如下所示的行:

<dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
<dynamicField name="*_is" type="int"    indexed="true"  stored="true"  multiValued="true"/>

These mean that if you add a field with a name ending in _i or _is , you'll be all set to go.这意味着如果您添加一个名称以_i_is结尾的字段,您将全部设置为 go。 These are usually enabled in the default schema, so if you have flexibility about what to call the field, you might be all set with this.这些通常在默认模式中启用,因此如果您可以灵活地调用该字段,您可能已经全部设置好了。

If neither of those options look promising, your third option is to wait for Solr 4.4 or 5.0 and upgrade (which will also take a reindex in all likelihood.).如果这些选项看起来都没有希望,您的第三个选择是等待 Solr 4.4 或 5.0 并升级(这也很可能需要重新索引。)。

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

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