2015-06-24 17:27:19 -04:00
|
|
|
[[java-query-dsl-has-child-query]]
|
|
|
|
==== Has Child Query
|
|
|
|
|
|
|
|
See {ref}/query-dsl-has-child-query.html[Has Child Query]
|
|
|
|
|
2017-07-13 05:24:22 -04:00
|
|
|
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.
|
|
|
|
|
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_child]
|
2015-06-24 17:27:19 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> child type to query against
|
|
|
|
<2> query
|
2016-11-28 11:33:40 -05:00
|
|
|
<3> score mode can be `ScoreMode.Avg`, `ScoreMode.Max`, `ScoreMode.Min`, `ScoreMode.None` or `ScoreMode.Total`
|