Vic*_*sky 2 indexing spring neo4j spring-data spring-data-neo4j
我怎样才能确保独特性:
目前我使用的是SDN 4.0.0.RC2.我查看了文档,似乎SDN 4现在不支持此功能(但将来会支持).我理解正确吗?
对于图形实体的属性?
使用cypher在属性上创建(可能是唯一的)索引:
CREATE INDEX ON :Person(name)
Run Code Online (Sandbox Code Playgroud)
唯一索引(又名约束):
CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS UNIQUE
Run Code Online (Sandbox Code Playgroud)
来自http://neo4j.com/docs/stable/query-schema-index.html#schema-index-create-index-on-a-label
您可以在引导spring上下文时自动执行此操作:
@Component
public class IndexCreator {
@Autowired
Neo4jTemplate neo4jTemplate;
@PostConstruct
public void createIndexes() {
try {
neo4jTemplate.execute("CREATE INDEX ON :Person(name)", null);
} catch (Exception ex) {
// index already exists?
}
}
}
Run Code Online (Sandbox Code Playgroud)
同时组合几个属性?
这不是直接支持的.您可以将多个属性连接成一个并在其上创建索引(同时保持原始属性能够访问它们).或者(正如迈克尔指出的那样)您可以使用array属性来存储多个值.
| 归档时间: |
|
| 查看次数: |
1048 次 |
| 最近记录: |