|
21 | 21 | import java.util.stream.Stream; |
22 | 22 |
|
23 | 23 | /** |
24 | | - * A {@link DocumentTemplate} to elasticsearch |
| 24 | + * An Elasticsearch-specific extension of {@link DocumentTemplate}, |
| 25 | + * providing a method to perform search queries using {@link SearchRequest}. |
| 26 | + * |
| 27 | + * This template allows executing Elasticsearch queries and retrieving results |
| 28 | + * as a stream of entities mapped by Eclipse JNoSQL. |
| 29 | + * |
| 30 | + * Example usage: |
| 31 | + * <pre> |
| 32 | + * {@code |
| 33 | + * @Inject |
| 34 | + * private ElasticsearchTemplate elasticsearchTemplate; |
| 35 | + * |
| 36 | + * SearchRequest request = new SearchRequest.Builder() |
| 37 | + * .index("documents") |
| 38 | + * .query(q -> q.match(m -> m.field("title").query("Eclipse JNoSQL"))) |
| 39 | + * .build(); |
| 40 | + * |
| 41 | + * Stream<Document> results = elasticsearchTemplate.search(request); |
| 42 | + * results.forEach(System.out::println); |
| 43 | + * } |
| 44 | + * </pre> |
| 45 | + * |
| 46 | + * @see DocumentTemplate |
25 | 47 | */ |
26 | 48 | public interface ElasticsearchTemplate extends DocumentTemplate { |
27 | 49 |
|
28 | 50 | /** |
29 | | - * Find entities from {@link SearchRequest} |
| 51 | + * Executes a search query using the provided {@link SearchRequest}. |
| 52 | + * The search query should be built using Elasticsearch's client API and passed |
| 53 | + * to this method. The results will be mapped to the specified entity type |
| 54 | + * and returned as a stream. |
30 | 55 | * |
31 | | - * @param query the query |
32 | | - * @return the objects from query |
33 | | - * @throws NullPointerException when query is null |
| 56 | + * @param <T> the entity type |
| 57 | + * @param query the Elasticsearch query request |
| 58 | + * @return a stream of entities resulting from the search query |
| 59 | + * @throws NullPointerException if the query is null |
34 | 60 | */ |
35 | 61 | <T> Stream<T> search(SearchRequest query); |
36 | 62 | } |
0 commit comments