In my web app, I would like to search the index created by Lucene, and get top 100 results for example.
These 100 results are type of class Document ( with fields named title, category and content, etc.) defined by myself. I put these into the List, but I can not adapt the list to make the pagination, with the help of org.springframework.data.domain.Page and org.springframework.data.domain.Pageable.
I knew that I can implement a customized repository that extends JpaRepository or PagingAndSortingRepository like
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
...
public interface Document Repository extends JpaRepository<Document, Long> {
@Query("SELECT d FROM document d WHERE d.category = :category")
Page<Product> findByCategory(@Param("category") String category,
Pageable pageable);
}
But in this case, I do not get the data from database, given by Lucene instead.
So I decided to collect the results in a List. The problem comes that I have to convert the List to Page to make the paginations.
Any good solutions? I'm not very familiar with Spring. I'm not trying implementing the pagination by myself.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire