# How HighLevelRestClient use complex-DSL?

**URL:** <https://discuss.elastic.co/t/how-highlevelrestclient-use-complex-dsl/260366>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 6, 2021, 4:08pm UTC](https://discuss.elastic.co/t/how-highlevelrestclient-use-complex-dsl/260366 "2021-01-06T16:08:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaiDaDao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daidadao/32/81846_2.png) [@DaiDaDao](https://discuss.elastic.co/u/DaiDaDao)\
**Post date:** [January 6, 2021, 4:08pm UTC](https://discuss.elastic.co/t/how-highlevelrestclient-use-complex-dsl/260366/1 "2021-01-06T16:08:02Z")

</div>

When I am trying to use DSL in HighLevelRestClient, I found there is no way to build a SearhSourceBuilder.

Then I tried  
`DyWrapperQueryBuilder wqb = new DyWrapperQueryBuilder(dsl);`  
I found that only simple DSL like  
`{"term" : { "user.id" : "kimchy" }}` can bu used.

But like  
`{"from":0,"size":0,"_source":{"includes":["COUNT"],"excludes":[]},"aggregations":{"COUNT(*)":{"value_count":{"field":"_index"}}}}`

is always return error msg like this  
`{"error":{"root_cause":[{"type":"parsing_exception","reason":"[from] query malformed, no start_object after query name","line":2,"col":11}],"type":"parsing_exception","reason":"[from] query malformed, no start_object after query name","line":2,"col":11},"status":400}`

I check my DSL is OK. So How can I use DSL like that in HighLevelRestClient ?

Thanks very much !

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 3, 2021, 4:08pm UTC](https://discuss.elastic.co/t/how-highlevelrestclient-use-complex-dsl/260366/2 "2021-02-03T16:08:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
