英文:
@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<String, Object>) ((Map) document.get("properties")).get("myObjectField")).put("enabled", 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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论