elasticsearch中的可编辑文档字段

分支

我的文档包含一个对象,该对象的属性在运行时可编辑(添加/删除/编辑)。

{
  "testIndex" : {
    "mappings" : {
      "documentTest" : {
        "properties" : {
          "typeTestId" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "createdDate" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "designation" : {
            "type" : "string",
            "fields" : {
              "raw" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "id" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "modifiedDate" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "stuff" : {
            "type" : "string"
          },
          "suggest" : {
            "type" : "completion",
            "analyzer" : "simple",
            "payloads" : true,
            "preserve_separators" : true,
            "preserve_position_increments" : true,
            "max_input_length" : 50,
            "context" : {
              "typeTestId" : {
                "type" : "category",
                "path" : "typeTestId",
                "default" : [ ]
              }
            }
          },
          "values" : {
            "properties" : {
              "Att1" : {
                "type" : "string"
              },
              "att2" : {
                "type" : "string"
              },
              "att400" : {
                "type" : "date",
                "format" : "dateOptionalTime"
              }
            }
          }
        }
      }
    }
  }
}

字段值是可以通过typeTest进行编辑的对象,因此,如果我在typeTestit中进行了更改,则应在此处反映出来。如果我创建一个新字段,没有问题,但是应该可以编辑或删除typeTest中的现有字段。例如,如果我删除values.att1,则所有documentTest都将丢失这些值,并且应更新映射。

就我所见,如果不重新编制索引,我们将无法做到这些。所以现在,我的解决方案是像在此问题中提到的那样删除弹性搜索中的字段,并让工作人员在需要时不时重新索引。

在我看来,这不是一个“解决方案”。在Elasticsearch中是否有更好的方法来拥有这种类型的文档?具有这种灵活性而不必时不时重新编制索引?

香港

您可以使用Update API删除,添加或修改字段。
问题是文档在Elasticsearch中是不可变的,因此当您使用update API进行某些更改时,它会以某种方式执行mark as deleted to old one and add a new one with the updates
删除和创建新文档对您是透明的,因此您不必重新索引或执行任何其他操作。不利的一面是,如果您打算修改大量文档(例如用于修改5百万个文档的更新查询),则节点的I / O密集度很高。
顺便说一句,这也适用于删除

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

标题文本字段在特定的 Word 文档中不可编辑

限制Excel中的可编辑字段

通过代码修改字段组中字段的可编辑性

从Elasticsearch文档中删除字段

访问重复控件中可编辑字段的值

如何限制用户在可编辑字段中添加图像

交互式网格中的可编辑字段

如何使 JFileChooser 中的“Look In”字段在 WINdows 上可编辑?

如何使reactjs中具有值的输入字段可编辑?

使主键字段在Flask-Admin中可编辑

AngularJs中可编辑的输入文本字段不会重置

为什么在 pgAdmin 中某些字段不可编辑?

如何在内容可编辑字段中渲染图像?

在不可编辑的字段中显示插入符的位置

Webix组合框中的不可编辑文本字段

React.js设计模式:从* parent *节点保存具有多个字段的可编辑文档

扩展Elasticsearch文档中的列表字段

在ElasticSearch中查找缺少字段的文档

iText PdfCopy 创建可编辑的 pdf 文档

包含HTML格式的页面编辑器中的Sitecore富文本字段不可编辑

Woocommerce管理员编辑订单页面常规部分中的自定义可编辑字段

输入字段和React,因为attr中的react id导致输入字段不可编辑

ElasticSearch - 如何按 JSON 字段中的特定字段查询文档

单击按钮时使字段可编辑

FullCalendar 事件缺少“可编辑”字段?

输入字段输入后不可编辑

为x可编辑字段输入小数

SwiftUI EKEventEditViewController字段不可编辑

在Openerp中使功能字段可编辑?