Neo4j Spring Data example missing annotation @Inde

2019-09-10 05:05发布

问题:

Trying to run the neo4j spring data example on http://projects.spring.io/spring-data-neo4j/

<dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>4.1.2.RELEASE</version>
    </dependency>
</dependencies>

And

@NodeEntity
public class Movie {

  @GraphId Long id;

  @Indexed(type = FULLTEXT, indexName = "search")
  String title;

  Person director;

  @RelatedTo(type="ACTS_IN", direction = INCOMING)
  Set<Person> actors;

  @RelatedToVia(type = "RATED")
  Iterable<Rating> ratings;

  @Query("start movie=node({self}) match 
          movie-->genre<--similar return similar")
  Iterable<Movie> similarMovies;
}

but the @Indexed(type = FULLTEXT, indexName = "search") does not seem to exist in <artifactId>spring-data-neo4j</artifactId>
Do I have to add anything else to the pom ? or is this deprecated and if so how should I do it?

回答1:

@Indexed was present in SDN 3, but not anymore in SDN 4. You have to manage indices and constraints yourself, using Cypher queries.

Shameless plug: you can use Liquigraph to manage your migrations.