Updated examples:
adapted cineasts examples to new cypher order by rule (expressions must be part of return) example dependency to Neo4j 1.8
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<neo4j.version>1.8</neo4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
</properties>
|
||||
|
||||
@@ -12,6 +12,6 @@ public interface MovieRecommendation {
|
||||
@ResultColumn("otherMovie")
|
||||
Movie getMovie();
|
||||
|
||||
@ResultColumn("avg(r3.stars)")
|
||||
@ResultColumn("rating")
|
||||
int getRating();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.neo4j.cineasts.domain.MovieRecommendation;
|
||||
import org.neo4j.cineasts.domain.User;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.neo4j.annotation.MapResult;
|
||||
import org.springframework.data.neo4j.annotation.Query;
|
||||
import org.springframework.data.neo4j.annotation.ResultColumn;
|
||||
import org.springframework.data.neo4j.repository.GraphRepository;
|
||||
import org.springframework.data.neo4j.repository.NamedIndexRepository;
|
||||
|
||||
@@ -20,12 +22,12 @@ public interface MovieRepository extends GraphRepository<Movie>, NamedIndexRepos
|
||||
|
||||
Page<Movie> findByTitleLike(String title, Pageable page);
|
||||
|
||||
@Query("start user=node({0}) " +
|
||||
" match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie " +
|
||||
" where r.stars >= 3 and r2.stars >= 3 and r3.stars >= 3 " +
|
||||
" return otherMovie, avg(r3.stars) " +
|
||||
" order by avg(r3.stars) desc, count(*) desc" +
|
||||
" limit 10")
|
||||
List<MovieRecommendation> getRecommendations(User user);
|
||||
@Query( "start user=node({0}) " +
|
||||
" match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie " +
|
||||
" where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars " +
|
||||
" return otherMovie, avg(r3.stars) as rating, count(*) as cnt" +
|
||||
" order by rating desc, cnt desc" +
|
||||
" limit 10" )
|
||||
List<MovieRecommendation> getRecommendations( User user );
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<neo4j.version>1.8</neo4j.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<jersey.version>1.4</jersey.version>
|
||||
|
||||
@@ -20,9 +20,9 @@ public interface MovieRepository extends GraphRepository<Movie>, NamedIndexRepos
|
||||
|
||||
@Query( "start user=node({0}) " +
|
||||
" match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie " +
|
||||
" where r.stars > 3 and r2.stars >= r.stars and r3.stars >= r.stars " +
|
||||
" return otherMovie, avg(r3.stars) " +
|
||||
" order by avg(r3.stars) desc, count(*) desc" +
|
||||
" where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars " +
|
||||
" return otherMovie, avg(r3.stars) as rating, count(*) as cnt" +
|
||||
" order by rating desc, cnt desc" +
|
||||
" limit 10" )
|
||||
List<MovieRecommendation> getRecommendations( User user );
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface MovieRepository extends GraphRepository<Movie>, NamedIndexRepos
|
||||
@ResultColumn( "otherMovie" )
|
||||
Movie getMovie();
|
||||
|
||||
@ResultColumn( "count(*)" )
|
||||
@ResultColumn( "rating" )
|
||||
int getRating();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ public interface MovieRecommendation {
|
||||
@ResultColumn("otherMovie")
|
||||
Movie getMovie();
|
||||
|
||||
@ResultColumn("avg(r3.stars)")
|
||||
@ResultColumn("rating")
|
||||
int getRating();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import org.neo4j.cineasts.domain.MovieRecommendation;
|
||||
import org.neo4j.cineasts.domain.User;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.neo4j.annotation.MapResult;
|
||||
import org.springframework.data.neo4j.annotation.Query;
|
||||
import org.springframework.data.neo4j.annotation.ResultColumn;
|
||||
import org.springframework.data.neo4j.repository.GraphRepository;
|
||||
import org.springframework.data.neo4j.repository.NamedIndexRepository;
|
||||
import org.springframework.data.neo4j.repository.RelationshipOperationsRepository;
|
||||
@@ -23,12 +25,12 @@ public interface MovieRepository extends GraphRepository<Movie>,
|
||||
|
||||
Page<Movie> findByTitleLike(String title, Pageable page);
|
||||
|
||||
@Query("start user=node({0}) " +
|
||||
" match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie " +
|
||||
" where r.stars >= 3 and r2.stars >= 3 and r3.stars >= 3 " +
|
||||
" return otherMovie, avg(r3.stars) " +
|
||||
" order by avg(r3.stars) desc, count(*) desc" +
|
||||
" limit 10")
|
||||
List<MovieRecommendation> getRecommendations(User user);
|
||||
|
||||
@Query( "start user=node({0}) " +
|
||||
" match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie " +
|
||||
" where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars " +
|
||||
" return otherMovie, avg(r3.stars) as rating, count(*) as cnt" +
|
||||
" order by rating desc, cnt desc" +
|
||||
" limit 10" )
|
||||
List<MovieRecommendation> getRecommendations( User user );
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<neo4j.version>1.8</neo4j.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring-security.version>3.1.0.RELEASE</spring-security.version>
|
||||
</properties>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<neo4j.version>1.8.M06</neo4j.version>
|
||||
<neo4j.version>1.8</neo4j.version>
|
||||
<spring.version>3.1.0.RELEASE</spring.version>
|
||||
<spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
|
||||
<aspectj.version>1.6.12</aspectj.version>
|
||||
|
||||
Reference in New Issue
Block a user