Skip to content

Commit 34a264c

Browse files
committed
added docs for wrapper query.
Closes #11591
1 parent 24d10ad commit 34a264c

File tree

6 files changed

+54
-0
lines changed

6 files changed

+54
-0
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/QueryDSLDocumentationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
7777
import static org.elasticsearch.index.query.QueryBuilders.typeQuery;
7878
import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery;
79+
import static org.elasticsearch.index.query.QueryBuilders.wrapperQuery;
7980
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.exponentialDecayFunction;
8081
import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction;
8182

@@ -449,4 +450,11 @@ public void testWildcard() {
449450
"k?mch*"); // <2>
450451
// end::wildcard
451452
}
453+
454+
public void testWrapper() {
455+
// tag::wrapper
456+
String query = "{\"term\": {\"user\": \"kimchy\"}}"; // <1>
457+
wrapperQuery(query);
458+
// end::wrapper
459+
}
452460
}

docs/java-api/query-dsl/special-queries.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ This query allows a script to act as a filter. Also see the
1818

1919
This query finds percolator queries based on documents.
2020

21+
<<java-query-dsl-wrapper-query,`wrapper` query>>::
22+
23+
A query that accepts other queries as json or yaml string.
24+
2125
include::mlt-query.asciidoc[]
2226

2327
include::script-query.asciidoc[]
2428

2529
include::percolate-query.asciidoc[]
2630

31+
include::wrapper-query.asciidoc[]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[java-query-dsl-wrapper-query]]
2+
==== Wrapper Query
3+
4+
See {ref}/query-dsl-wrapper-query.html[Wrapper Query]
5+
6+
["source","java",subs="attributes,callouts,macros"]
7+
--------------------------------------------------
8+
include-tagged::{query-dsl-test}[wrapper]
9+
--------------------------------------------------
10+
11+
<1> query defined as query builder

docs/java-rest/high-level/query-builders.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ This page lists all the available search queries with their corresponding `Query
8282
| {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()]
8383
| {ref}/query-dsl-script-query.html[Script] | {query-ref}/ScriptQueryBuilder.html[ScriptQueryBuilder] | {query-ref}/QueryBuilders.html#scriptQuery-org.elasticsearch.script.Script-[QueryBuilders.scriptQuery()]
8484
| {ref}/query-dsl-percolate-query.html[Percolate] | {percolate-ref}/PercolateQueryBuilder.html[PercolateQueryBuilder] |
85+
| {ref}/query-dsl-wrapper-query.html[Wrapper] | {query-ref}/WrapperQueryBuilder.html[WrapperQueryBuilder] | {query-ref}/QueryBuilders.html#wrapperQuery-java.lang.String-[QueryBuilders.wrapperQuery()]
8586
|======
8687

8788
==== Span queries

docs/reference/query-dsl/special-queries.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ This query allows a script to act as a filter. Also see the
1919
This query finds queries that are stored as documents that match with
2020
the specified document.
2121

22+
<<query-dsl-wrapper-query,`wrapper` query>>::
23+
24+
A query that accepts other queries as json or yaml string.
25+
2226
include::mlt-query.asciidoc[]
2327

2428
include::script-query.asciidoc[]
2529

2630
include::percolate-query.asciidoc[]
2731

32+
include::wrapper-query.asciidoc[]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[[query-dsl-wrapper-query]]
2+
=== Wrapper Query
3+
4+
A query that accepts any other query as base64 encoded string.
5+
6+
[source,js]
7+
--------------------------------------------------
8+
GET /_search
9+
{
10+
"query" : {
11+
"wrapper": {
12+
"query" : "eyJ0ZXJtIiA6IHsgInVzZXIiIDogIktpbWNoeSIgfX0=" <1>
13+
}
14+
}
15+
}
16+
--------------------------------------------------
17+
// CONSOLE
18+
19+
<1> Base64 encoded string: `{"term" : { "user" : "Kimchy" }}`
20+
21+
This query is more useful in the context of the Java high-level REST client or
22+
transport client to also accept queries as json formatted string.
23+
In these cases queries can be specified as a json or yaml formatted string or
24+
as a query builder (which is a available in the Java high-level REST client).

0 commit comments

Comments
 (0)