我有以下带有复合索引的BaseContent类:
public abstract class BaseContent<D extends BaseContentDTO> extends BaseEntity {
/* The FULLTEXT index allows to search on non case-sensitive queries */
@Indexed(indexName = "search_content")
@NotNull
protected String name;
@Indexed(indexName = "search_content")
protected Integer year;
}现在,我需要将索引更新为全文索引,以便支持不区分大小写的搜索。
我将其修改为:
public abstract class BaseContent<D extends BaseContentDTO> extends BaseEntity {
/* The FULLTEXT index allows to search on non case-sensitive queries */
@Indexed(indexName = "search_content", indexType=IndexType.FULLTEXT)
@NotNull
protected String name;
@Indexed(indexName = "search_content", indexType=IndexType.FULLTEXT)
protected Integer year;
}现在,当尝试引发服务器时,我得到了异常:
Index with the same name but different config exists!我手动删除了之前的索引,当再次提升服务器时,它似乎正确地创建了索引。
但是,当查询现有数据时,我再次得到异常,并且我意识到它没有再次重新索引现有数据。
有没有办法对现有数据重新编制索引?
谢谢卡梅尔
发布于 2014-01-01 02:02:33
可以使用index类的add方法向现有索引添加节点,如下面的代码片段所示:
@Autowired Neo4jOperations neo4jOperations;
Index index = neo4jOperations.getGraphDatabase().getIndex("search_content");
Collection<YourClass> objects = neo4jOperations.findAll(YourClass.class).as(Collection.class);
for (YourClass object: objects) {
Node node = neo4jOperations.getNode(object.getId());
index.add(node, "name", node.getProperty("name"));
index.add(node, "year", node.getProperty("year"));
}我使用占位符类名YourClass,因为您没有在代码中显示具体的类名。
https://stackoverflow.com/questions/20857156
复制相似问题