@Field(type = FieldType.Object, enabled = false)

huangapple go评论75阅读模式
英文:

@Field with type = FieldType.Object and enabled = false

问题

根据这份文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html,可以禁用对象的解析,但在 @Field 中我没有看到任何映射选项。

我不得不使用这个不太好的方法(在 indexOperations.createMapping() 之后):

(Map<String, Object>) ((Map) document.get("properties")).get("myObjectField")).put("enabled", false);

有没有更好的方法来实现这个?我不想使用映射文件。

英文:

According to this documentation <https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html> it's possible to disable parsing of the object, but I don't see any mapping option for that in @Field.
I had to use this dirty hack (after indexOperations.createMapping()):

(Map&lt;String, Object&gt;) ((Map) document.get(&quot;properties&quot;)).get(&quot;myObjectField&quot;)).put(&quot;enabled&quot;, false);

Is there any better way to do that? I don't want to use mapping files.

答案1

得分: 1

这是@Field注解的参数之一,你是对的。
我为此创建了一个问题,今晚会尝试解决,以便在下一个版本中包含。

截至目前为止,除了映射文件或您的解决方案外,没有其他方法(仅在禁用自动索引创建时才有效,否则存储库设置会创建索引和映射)

编辑于2020年09月10日:将从版本4.1.RC2中包含。

英文:

That one is missing as parameter of the @Field annotation, you're right.
I created an issue for that, will try to get to it this evening to have it in the next version.

And no, up to that, there is no other way besides mapping files or your solution (which only works, if you don't have automatic index creation disabled, otherwise the repository setup will create the index and mapping)

Edit 09.10.2020: will be included from version 4.1.RC2 on

huangapple
  • 本文由 发表于 2020年10月7日 16:26:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64240140.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定