Open DevShivmohan opened 5 months ago
{
"pageNumber": 0,
"pageSize": 20,
"totalElements": 20,
"totalPages": 4,
"lastPage": false,
"content": [
{
"id": 31,
"name": "Xenophilius Lovegood",
"bio": "Father of Luna and editor of The Quibbler."
},
{
"id": 5,
"name": "Vincent Crabbe Sr.",
"bio": "Father of Crabbe and death-eater who escaped Azkaban."
},
{
"id": 6,
"name": "Vincent Crabbe",
"bio": "Slytherin student who was best friends with Goyle and followed Draco."
},
{
"id": 25,
"name": "Viktor Krum",
"bio": "Participant in the Triwizard tournament. Dated Hermione."
},
{
"id": 15,
"name": "Vernon Dursley",
"bio": "Harry's muggle uncle."
},
{
"id": 44,
"name": "Tom Riddle Sr.",
"bio": "Muggle father of Voldemort who was killed by him."
},
{
"id": 2,
"name": "Sirius Black",
"bio": "Best friend of James Potter and godfather of Harry."
},
{
"id": 48,
"name": "Severus Snape",
"bio": "Head of the Slytherin house and saved Harry in many occasions."
},
{
"id": 17,
"name": "Seamus Finnigan",
"bio": "Harry's friend and member of Dumbledore's army."
},
{
"id": 23,
"name": "Rubeus Hagrid",
"bio": "Half-giant who loves Harry. He was the keeper of Keys and Grounds at Hogwards."
},
{
"id": 59,
"name": "Ron Weasley",
"bio": "Harry's best friend. Marries Hermione."
},
{
"id": 47,
"name": "Rita Skeeter",
"bio": "Reporter at the Daily Prophet."
},
{
"id": 32,
"name": "Remus Lupin",
"bio": "Friend of James Potter and werewolf. He married Nymphadora."
},
{
"id": 1,
"name": "Regulus Arcturus Black",
"bio": "Brother of Sirius. Used to be a Death Eater but defected."
},
{
"id": 43,
"name": "Quirinus Quirrell",
"bio": "Possessed by Voldemort. Defence against the Dark Arts professor."
},
{
"id": 14,
"name": "Petunia Dursley",
"bio": "Harry's aunt and sister of Lily."
},
{
"id": 39,
"name": "Peter Pettigrew",
"bio": "Betrays James and Lily Potter. Follower of Voldemort."
},
{
"id": 58,
"name": "Percy Weasley",
"bio": "Third son of Arthur and Molly. He is a Gryffindor prefect."
},
{
"id": 36,
"name": "Olympe Maxime",
"bio": "Half-giantess and headmistress of Beauxbatons."
},
{
"id": 49,
"name": "Nymphadora Tonks",
"bio": "Married Remus Lupin and was killed by Bellatrix."
}
]
}
code block
@Repository
public interface NGramRepository extends JpaRepository<NGram,Integer> {
@Query(nativeQuery = true,value = ApiConstant.N_GRAM_SEARCH_QUERY)
List<NGram> findByNgram(@Param("keyword") String keyword);
@Query(value = "SELECT *, MATCH(name, bio) AGAINST(:keyword) AS score FROM n_gram WHERE MATCH(name, bio) AGAINST(:keyword) ORDER BY score DESC",
countQuery = "SELECT COUNT(*) FROM n_gram WHERE MATCH(name, bio) AGAINST(:keyword)",
nativeQuery = true)
Page<NGram> findAllWithPagination(@Param("keyword") String keyword, Pageable pageable);
}
Implementation Pagination, Filter and Sorting at DB layer
Service layer implementation
API layer implementation
Models
Entity