2015-06-24 17:27:19 -04:00
|
|
|
[[java-query-dsl-has-parent-query]]
|
|
|
|
==== Has Parent Query
|
|
|
|
|
|
|
|
See {ref}/query-dsl-has-parent-query.html[Has Parent]
|
|
|
|
|
2017-07-13 05:24:22 -04:00
|
|
|
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);
|
2018-05-17 08:23:08 -04:00
|
|
|
client.addTransportAddress(new TransportAddress(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9300)));
|
2017-07-13 05:24:22 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
Otherwise the parent-join module doesn't get loaded and the `has_parent` query can't be used from the transport client.
|
|
|
|
|
2017-05-02 13:00:56 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
2017-05-02 13:00:56 -04:00
|
|
|
include-tagged::{query-dsl-test}[has_parent]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> parent type to query against
|
|
|
|
<2> query
|
2017-05-02 13:00:56 -04:00
|
|
|
<3> whether the score from the parent hit should propagate to the child hit
|