-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Search elements are now returned paged (#149)
* feat: search elements are now returned paged --------- Signed-off-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com> Co-authored-by: LE SAULNIER Kevin <kevin.lesaulnier@rte-france.com> Co-authored-by: jamal-khey <myjamal89@gmail.com>
- Loading branch information
1 parent
a9bd7e4
commit 6607024
Showing
6 changed files
with
130 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/org/gridsuite/directory/server/elasticsearch/ESUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.gridsuite.directory.server.elasticsearch; | ||
|
||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.elasticsearch.core.SearchHit; | ||
import org.springframework.data.elasticsearch.core.SearchHits; | ||
|
||
import java.util.List; | ||
|
||
public final class ESUtils { | ||
|
||
private ESUtils() { | ||
// This constructor is private to prevent instantiation of the utility class. | ||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); | ||
} | ||
|
||
public static <T> Page<T> searchHitsToPage(SearchHits<T> searchHits, Pageable pageable) { | ||
List<T> content = searchHits.stream().map(SearchHit::getContent).toList(); | ||
return new PageImpl<>(content, pageable, searchHits.getTotalHits()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.