누구나 @GraphId
과 @Index
주석의 차이점을 설명 할 수 있습니까? org.neo4j.ogm.annotation
? 지금은 문서를 읽은 후 Neo4j 내부 논리에 대한 식별자를 만드는 데 @GraphId
이 사용되고 시간 경과에 따라 사용자가 재사용 할 수 있기 때문에 사용자가 의존해서는 안됩니다. 그러나 @Index
은 어떨까요? 내가 알고있는 것처럼스프링 데이터 Neo4j @GraphId 및 @Index
, 그래프 기반 데이터베이스의 주요 장점은 우리는 우리가해야 할 일은 그냥 시작에서 그래프를 통과하기 때문에 일이 쉽게되기 시작할에서 노드/관계를 알면 마디. 색인 생성은 그렇게하는 데 도움이됩니다. 그래서 우리는 START n = node:index_name(property_name = value)
과 같은 것을 쓸 수 있고, 인덱스 된 노드에서 그래프를 'property_name'속성에 의해 exloring하기 시작할 수 있습니다, 맞습니까? 당신이 String name
속성이 @Index
와 주석이 볼 수 있듯이
@ToString
@NodeEntity(label = "Event")
@NoArgsConstructor
public class Event{
public Event(String eventName, LocalDate dateTime){
this.name = eventName;
this.date = dateTime;
}
public Event(Long id, String eventName, LocalDate dateTime){
this(eventName, dateTime);
this.id = id;
}
@Getter
@GraphId
private Long id;
@Getter
@Index(unique = true, primary = true)
@Property(name = "name")
private String name;
@Getter
@Property(name = "date")
@Convert(DateConverter.class)
private LocalDate date;
}
:
그래서,이 엔티티를 고려하십시오. 실제로 Cypher 쿼리를 작성하여 name = 'something'인 노드에서 실제로 시작할 수 있습니까? 색인 이름은 무엇입니까? 또는 스프링 데이터 Neo4j 4.2.0.RELEASE는 단지 MATCH (event:Event {name = 'somehting'} ...
으로 쓸 때 그 자체로 나타납니다? 여기
@Repository
public interface EventRepository extends Neo4jRepository<Event, String>{
Event findOne(String eventName);
}
repositry 클래스와 당신은 내가 저장소가 관리하는 엔티티의 ID의 형식으로 String
를 사용하고 볼 수 있습니다, 그래서 봄이 Event findOne(String eventName);
name
속성을 사용하여 가정 등
예, 그렇습니다. 이것 좀 봐. 도움이 될 것입니다. http://graphaware.com/neo4j/2015/01/16/neo4j-graph-model-design-labels-versus-indexed-properties.html – pvpkiran