我有一个以_id作为参数的文档。我有以下JSON在弹性搜索中使用_id作为文档标识符
{
"_id":{
"$oid":"52af48b5d55148fa0c199643"
},
"email":"[email protected]"
}
相应的Java类:
@Document(indexName = "Test")
public class Test {
@Id
@ObjectId
private String _id;
private String email;
}
JSON对象的转换成功但在将数据保存到弹性搜索的问题。
org.elasticsearch.index.mapper.MapperParsingException: Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters
我已经看到了一些参考,来到我不能使用_id下结论。但要寻找一种方式来使用JsonProperty,但它也为我猜的ObjectId使用JsonProperty内部不起作用。
请提供建议
你可以请建议一些JSON适配器转换在这些情况下...我不能改变JSON格式,因为它来自外部来源 – Dev