added docs for `wrapper` query.

Closes #11591
This commit is contained in:
Martijn van Groningen 2018-03-14 11:51:22 +01:00
parent 24d10adaab
commit 34a264c375
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
6 changed files with 54 additions and 0 deletions

View File

@ -76,6 +76,7 @@ import static org.elasticsearch.index.query.QueryBuilders.termQuery;
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
import static org.elasticsearch.index.query.QueryBuilders.typeQuery;
import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery;
import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.exponentialDecayFunction;
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction;
@ -449,4 +450,11 @@ public class QueryDSLDocumentationTests extends ESTestCase {
"k?mch*"); // <2>
// end::wildcard
}
public void testWrapper() {
// tag::wrapper
String query = "{\"term\": {\"user\": \"kimchy\"}}"; // <1>
wrapperQuery(query);
// end::wrapper
}
}

View File

@ -18,9 +18,14 @@ This query allows a script to act as a filter. Also see the
This query finds percolator queries based on documents.
<<java-query-dsl-wrapper-query,`wrapper` query>>::
A query that accepts other queries as json or yaml string.
include::mlt-query.asciidoc[]
include::script-query.asciidoc[]
include::percolate-query.asciidoc[]
include::wrapper-query.asciidoc[]

View File

@ -0,0 +1,11 @@
[[java-query-dsl-wrapper-query]]
==== Wrapper Query
See {ref}/query-dsl-wrapper-query.html[Wrapper Query]
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{query-dsl-test}[wrapper]
--------------------------------------------------
<1> query defined as query builder

View File

@ -82,6 +82,7 @@ This page lists all the available search queries with their corresponding `Query
| {ref}/query-dsl-mlt-query.html[More Like This] | {query-ref}/MoreLikeThisQueryBuilder.html[MoreLikeThisQueryBuilder] | {query-ref}/QueryBuilders.html#moreLikeThisQuery-org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item:A-[QueryBuilders.moreLikeThisQuery()]
| {ref}/query-dsl-script-query.html[Script] | {query-ref}/ScriptQueryBuilder.html[ScriptQueryBuilder] | {query-ref}/QueryBuilders.html#scriptQuery-org.elasticsearch.script.Script-[QueryBuilders.scriptQuery()]
| {ref}/query-dsl-percolate-query.html[Percolate] | {percolate-ref}/PercolateQueryBuilder.html[PercolateQueryBuilder] |
| {ref}/query-dsl-wrapper-query.html[Wrapper] | {query-ref}/WrapperQueryBuilder.html[WrapperQueryBuilder] | {query-ref}/QueryBuilders.html#wrapperQuery-java.lang.String-[QueryBuilders.wrapperQuery()]
|======
==== Span queries

View File

@ -19,9 +19,14 @@ This query allows a script to act as a filter. Also see the
This query finds queries that are stored as documents that match with
the specified document.
<<query-dsl-wrapper-query,`wrapper` query>>::
A query that accepts other queries as json or yaml string.
include::mlt-query.asciidoc[]
include::script-query.asciidoc[]
include::percolate-query.asciidoc[]
include::wrapper-query.asciidoc[]

View File

@ -0,0 +1,24 @@
[[query-dsl-wrapper-query]]
=== Wrapper Query
A query that accepts any other query as base64 encoded string.
[source,js]
--------------------------------------------------
GET /_search
{
"query" : {
"wrapper": {
"query" : "eyJ0ZXJtIiA6IHsgInVzZXIiIDogIktpbWNoeSIgfX0=" <1>
}
}
}
--------------------------------------------------
// CONSOLE
<1> Base64 encoded string: `{"term" : { "user" : "Kimchy" }}`
This query is more useful in the context of the Java high-level REST client or
transport client to also accept queries as json formatted string.
In these cases queries can be specified as a json or yaml formatted string or
as a query builder (which is a available in the Java high-level REST client).