我有一个 mongodb
集合 term
,具有以下结构
{
"_id" : "00002c34-a4ca-42ee-b242-e9bab8e3a01f",
"terminologyClass" : "USER",
"code" : "X67",
"terminology" : "some term related notes",
"notes" : "some notes"
}
一份代表术语集合的Java类,命名为Term.java
@Document
public class Term{
@Id
protected String termId;
@Indexed
protected String terminologyClass;
@Indexed(unique=true)
protected String code;
@Indexed
protected String terminology;
protected String notes;
//getters & setters
}
我有许多term
集合中的文档。现在,我正在将一个新字段添加到 Term.java
中:
@Indexed
protected String status;
在向
term
集合中插入新术语时,添加Term.java
字段status
后,我遇到了如下异常:
com.mongodb.MongoException: Index with name: code already exists with different options
我使用的MongoDB版本为2.6.5,spring-data-mongodb版本为1.3.2。