在 solr schema.xml 中添加字段
我正在使用 solr 在我的数据库上进行搜索,并尝试在conf/schema.xml 中添加一个新字段(文章的publisher_id),以在对我的数据库进行搜索后获取publisher_id 的值,我没有找到与此字段等效的任何字段名称。那么我如何将其添加为 schema.xml 中的字段,以便与文章的搜索值(正文、标题、日期和publisher_id)一起返回?
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. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先:publisher_id中存储了什么样的数据?
如果是数字(int、log),则添加相应类型的字段,例如:
在 schema.xml 添加字段后,您必须重新启动 solr 实例并重建索引。
First of all: what kind of data is stored in publisher_id?
If it is a number (int, log) so add an field with the corresponding type, like:
After adding a field to the schema.xml, you have to restart the solr-instance and rebuild your index.
请注意,动态字段添加已在 Solr 4.4 和 Solr 5.0 中添加...两者均尚未发布。
同时,如果您想向索引添加字段,您有两种选择。首先,您可以采用困难的方法:将字段添加到您的架构中,清除索引,重新启动 Solr 并重新索引所有内容。这往往有点站不住脚。
或者,您可以使用动态字段声明。如果您查看架构,您将看到类似以下的行:
这意味着如果您添加名称以
_i
或_is
结尾的字段,您将一切准备就绪。这些通常在默认模式中启用,因此如果您可以灵活地调用该字段,那么您可能已经准备好了。如果这两个选项看起来都没有希望,那么您的第三个选择是等待 Solr 4.4 或 5.0 并升级(这也很可能需要重新索引!)。
Note that dynamic field additions have been added in Solr 4.4 and Solr 5.0...neither of which are yet released.
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. 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:
These mean that if you add a field with a name ending in
_i
or_is
, you'll be all set to 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!).