将新字段更新到现有文档 [英] Update a new field to existing document

查看:29
本文介绍了将新字段更新到现有文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能将新字段更新为现有文档?例如:有一个包含多个字段的文档,例如

is there possibility to update a new field to an existing document? For example: There is an document with several fields, e.g.

ID=99999
Field1:text
Field2:text

该文档已经在索引中,现在我想在没有旧数据的情况下向该文档插入一个新字段:

This document is already in the index, now I want to insert a new field to this document WITHOUT the old data:

ID=99999
Field3:text

现在,旧文档将被删除,并创建一个带有 ID 的新文档.因此,如果我现在搜索 ID 99999,结果将是:

For now, the old document will be deleted and a new document with the ID will be created. So if I now search for the ID 99999 the result will be:

ID=99999
Field3:text

我在 Solr Wiki 上读到的

I read this at the Solr Wiki

如何更新现有文档的特定字段?

How can I update a specific field of an existing document?

我想更新文档中的特定字段,这可能吗?我只需要为 > 特定文档索引一个字段.我是否必须为此索引所有文档?

I want update a specific field in a document, is that possible? I only need to index one field for >a specific document. Do I have to index all the document for this?

不,只有一个文件.假设您有一个 CMS 并且您编辑了一个文档.您只需要通过对整个文档(而不是仅一个字段)使用 add solr 语句来重新索引该文档.

No, just the one document. Let's say you have a CMS and you edit one document. You will need to re-index this document only by using the the add solr statement for the whole document (not one field only).

在 Lucene 中更新文档的操作实际上是删除后添加.您将需要 > 添加完整的文档,因为在 Lucene 中没有这样的仅更新字段"语义.

In Lucene to update a document the operation is really a delete followed by an add. You will need >to add the complete document as there is no such "update only a field" semantics in Lucene.

那么有什么解决办法吗?这个功能会不会在后续版本中实现(我目前使用的是3.6.0).作为一种解决方法,我考虑编写一个脚本或一个应用程序,它将收集现有字段、添加新字段并更新整个文档.但我认为这会影响性能.您还有其他想法吗?

So is there any solution for this? Will this function be implemented in a further version (I currently use 3.6.0). As a workaround, I thought about writing a script or an application, which will collect the existing fields, add the new field and update the whole document. But I think this will suffer performance. Do you have any other ideas?

最好的问候

推荐答案

我有 2 个答案给你(或多或少都不好):

I have 2 answers for you (both more or less bad):

  1. 要更新 Solr 中的文档,您必须重新索引整个文档(要更新文档 ID:99999 中的 Field3,您必须使用所有字段的值重新索引该文档)
  2. 在 Solr 4 中,他们实现了类似的功能,但他们有一个条件:必须存储所有字段,而不仅仅是索引.正在发生的事情是他们在后台使用存储的值和重新索引文档.如果你有兴趣,有关于它的好文章:http://solr.pl/en/2012/07/09/solr-4-0-partial-documents-update/ 这个解决方案有明显的缺陷,那就是存储时索引的大小所有字段.
  1. To update filed with in document in Solr you have to reindex whole document (to update Field3 within document ID:99999 you have to reindex that document with values for all fields)
  2. In Solr 4 they implemented feature like that, but they have a condition: all fields have to be stored, not just indexed. What is happening that is they are using stored values and reindexing document in the background. If you are interested, there is nice article about it: http://solr.pl/en/2012/07/09/solr-4-0-partial-documents-update/ This solution have obvious flaw and that is size of index when you are storing all fields.

我希望这能帮助您解决问题.如果您还有其他问题,请提问

I hope that this will help you with your problem. If you have some more questions, please ask

这篇关于将新字段更新到现有文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆