[Docs] Add sorting and source filtering section to client docs (#25767)

This commit is contained in:
Christoph Büscher 2017-07-18 16:58:46 +02:00 committed by GitHub
parent 5c5d723b86
commit 43bfe06759
2 changed files with 44 additions and 1 deletions

View file

@ -82,6 +82,34 @@ After this, the `SearchSourceBuilder` only needs to be added to the
include-tagged::{doc-tests}/SearchDocumentationIT.java[search-source-setter]
--------------------------------------------------
===== Specifying Sorting
The `SearchSourceBuilder` allows to add one or more `SortBuilder` instances. There are four special implementations (Field-, Score-, GeoDistance- and ScriptSortBuilder).
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/SearchDocumentationIT.java[search-source-sorting]
--------------------------------------------------
<1> Sort descending by `_score` (the default)
<2> Also sort ascending by `_id` field
===== Source filtering
By default, search requests return the contents of the document `_source` but like in the Rest API you can overwrite this behavior. For example, you can turn off `_source` retrieval completely:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/SearchDocumentationIT.java[search-source-filtering-off]
--------------------------------------------------
The method also accepts an array of one or more wildcard patterns to control which fields get included or excluded in a more fine grained way:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/SearchDocumentationIT.java[search-source-filtering-includes]
--------------------------------------------------
[[java-rest-high-request-highlighting]]
===== Requesting Highlighting