diff --git a/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc b/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc index 7dd13bb88..8cb90d08e 100644 --- a/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc +++ b/src/main/asciidoc/reference/elasticsearch-repository-queries.adoc @@ -274,7 +274,8 @@ Repository methods can be defined to have the following return types for returni * `Stream` * `SearchHits` * `List>` -* `Stream<>>SearchHit>` +* `Stream>` +* `SearchPage` [[elasticsearch.query-methods.at-query]] == Using @Query Annotation @@ -284,8 +285,21 @@ Repository methods can be defined to have the following return types for returni [source,java] ---- interface BookRepository extends ElasticsearchRepository { - @Query("{\"bool\" : {\"must\" : {\"field\" : {\"name\" : \"?0\"}}}}") + @Query("{\"match\": {\"name\": {\"query\": \"?0\"}}}") Page findByName(String name,Pageable pageable); } ---- +The String that is set as the annotation argument must be a valid Elasticsearch JSON query. It will be sent to Easticsearch as value of the query element; if for example the function is called with the parameter _John_, it would produce the following query body: +[source,json] +---- +{ + "query": { + "match": { + "name": { + "query": "John" + } + } + } +} +---- ====