diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java index 7e84b266f7f..789d237c5a3 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java @@ -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 + } } diff --git a/docs/java-api/query-dsl/special-queries.asciidoc b/docs/java-api/query-dsl/special-queries.asciidoc index 4e4d59a6d4a..bca3bde3b3f 100644 --- a/docs/java-api/query-dsl/special-queries.asciidoc +++ b/docs/java-api/query-dsl/special-queries.asciidoc @@ -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. +<>:: + +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[] diff --git a/docs/java-api/query-dsl/wrapper-query.asciidoc b/docs/java-api/query-dsl/wrapper-query.asciidoc new file mode 100644 index 00000000000..3bdf3cc69d3 --- /dev/null +++ b/docs/java-api/query-dsl/wrapper-query.asciidoc @@ -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 diff --git a/docs/java-rest/high-level/query-builders.asciidoc b/docs/java-rest/high-level/query-builders.asciidoc index 88204baa874..32a3b06505b 100644 --- a/docs/java-rest/high-level/query-builders.asciidoc +++ b/docs/java-rest/high-level/query-builders.asciidoc @@ -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 diff --git a/docs/reference/query-dsl/special-queries.asciidoc b/docs/reference/query-dsl/special-queries.asciidoc index 3e3c140d6f5..a062fa7ddb1 100644 --- a/docs/reference/query-dsl/special-queries.asciidoc +++ b/docs/reference/query-dsl/special-queries.asciidoc @@ -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. +<>:: + +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[] diff --git a/docs/reference/query-dsl/wrapper-query.asciidoc b/docs/reference/query-dsl/wrapper-query.asciidoc new file mode 100644 index 00000000000..4ffef5bfc6b --- /dev/null +++ b/docs/reference/query-dsl/wrapper-query.asciidoc @@ -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). \ No newline at end of file