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 50b30d69348..65e47b63be0 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 @@ -28,6 +28,7 @@ import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.index.query.GeoShapeQueryBuilder; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder.FilterFunctionBuilder; +import org.elasticsearch.join.query.JoinQueryBuilders; import org.elasticsearch.script.Script; import org.elasticsearch.script.ScriptType; import org.elasticsearch.test.ESTestCase; @@ -77,8 +78,6 @@ import static org.elasticsearch.index.query.QueryBuilders.typeQuery; import static org.elasticsearch.index.query.QueryBuilders.wildcardQuery; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.exponentialDecayFunction; import static org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders.randomFunction; -import static org.elasticsearch.join.query.JoinQueryBuilders.hasChildQuery; -import static org.elasticsearch.join.query.JoinQueryBuilders.hasParentQuery; /** * Examples of using the transport client that are imported into the transport client documentation. @@ -218,7 +217,7 @@ public class QueryDSLDocumentationTests extends ESTestCase { public void testHasChild() { // tag::has_child - hasChildQuery( + JoinQueryBuilders.hasChildQuery( "blog_tag", // <1> termQuery("tag","something"), // <2> ScoreMode.None); // <3> @@ -227,7 +226,7 @@ public class QueryDSLDocumentationTests extends ESTestCase { public void testHasParent() { // tag::has_parent - hasParentQuery( + JoinQueryBuilders.hasParentQuery( "blog", // <1> termQuery("tag","something"), // <2> false); // <3> diff --git a/docs/java-api/query-dsl/has-child-query.asciidoc b/docs/java-api/query-dsl/has-child-query.asciidoc index fc29e8a9028..300b32e1922 100644 --- a/docs/java-api/query-dsl/has-child-query.asciidoc +++ b/docs/java-api/query-dsl/has-child-query.asciidoc @@ -3,6 +3,17 @@ See {ref}/query-dsl-has-child-query.html[Has Child Query] +When using the `has_child` query it is important to use the `PreBuiltTransportClient` instead of the regular client: + +[source,java] +-------------------------------------------------- +Settings settings = Settings.builder().put("cluster.name", "elasticsearch").build(); +TransportClient client = new PreBuiltTransportClient(settings); +client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9300))); +-------------------------------------------------- + +Otherwise the parent-join module doesn't get loaded and the `has_child` query can't be used from the transport client. + ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{query-dsl-test}[has_child] diff --git a/docs/java-api/query-dsl/has-parent-query.asciidoc b/docs/java-api/query-dsl/has-parent-query.asciidoc index 6ebf01be8c3..63711c399f7 100644 --- a/docs/java-api/query-dsl/has-parent-query.asciidoc +++ b/docs/java-api/query-dsl/has-parent-query.asciidoc @@ -3,6 +3,17 @@ See {ref}/query-dsl-has-parent-query.html[Has Parent] +When using the `has_parent` query it is important to use the `PreBuiltTransportClient` instead of the regular client: + +[source,java] +-------------------------------------------------- +Settings settings = Settings.builder().put("cluster.name", "elasticsearch").build(); +TransportClient client = new PreBuiltTransportClient(settings); +client.addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9300))); +-------------------------------------------------- + +Otherwise the parent-join module doesn't get loaded and the `has_parent` query can't be used from the transport client. + ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{query-dsl-test}[has_parent]