1234567891011121314151617181920212223 |
- [[java-query-dsl-has-parent-query]]
- ==== Has Parent Query
- 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 TransportAddress(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]
- --------------------------------------------------
- <1> parent type to query against
- <2> query
- <3> whether the score from the parent hit should propagate to the child hit
|