# Parsing Query DSL outside of a SearchSource

**URL:** <https://forum.opensearch.org/t/parsing-query-dsl-outside-of-a-searchsource/10579>\
**Category:** OpenSearch\
**Created:** [August 10, 2022, 3:42pm UTC](https://forum.opensearch.org/t/parsing-query-dsl-outside-of-a-searchsource/10579 "2022-08-10T15:42:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acruise](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/acruise/32/3721_2.png) [@acruise](https://forum.opensearch.org/u/acruise)\
**Post date:** [August 10, 2022, 3:42pm UTC](https://forum.opensearch.org/t/parsing-query-dsl-outside-of-a-searchsource/10579/1 "2022-08-10T15:42:53Z")

</div>

Hey folks, I’m building software that needs to be able to parse search and timeseries requests from Kibana. I started out by taking a dependency on `org.opensearch:opensearch:2.1.0` so I could play tricks like this:

```nohighlight
    fun parseSearchSource(body: ObjectNode): SearchSourceBuilder {
        val xp = XContentType.JSON.xContent()
            .createParser(OpenSearchPluginRegistry.registry, DeprecationHandler.IGNORE_DEPRECATIONS, body.toString())

        return SearchSourceBuilder.fromXContent(xp)
    }

```

But now I’d like to be able to parse requests from future versions of Elasticsearch as well, specifically one that includes `runtime_mappings`, which I know isn’t supported in OS. I don’t mind hand-writing Jackson codecs for most of these outer data types, but the Query DSL (i.e. the `query` field in a SearchSource) specifically is a bear to parse, so if I can get away with it, I’d like to assume it’s changing less frequently, and continue to use OpenSearch’s hand-written parser to handle the Query DSL, but at the moment I’m having trouble isolating that functionality in a useful way.

The code that parses a `QueryBuilder` from a `StreamInput` seems simple enough but that appears to only work with Transport data, and I need to parse from JSON.

Any tips? Thanks!

---

<div class="post-metadata">

**Author:** ![acruise](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/acruise/32/3721_2.png) [@acruise](https://forum.opensearch.org/u/acruise)\
**Post date:** [August 10, 2022, 3:47pm UTC](https://forum.opensearch.org/t/parsing-query-dsl-outside-of-a-searchsource/10579/2 "2022-08-10T15:47:53Z")

</div>

lol, literally single-digit minutes after posting this, I found `AbstractQueryBuilder#parseInnerQueryBuilder(XContentParser parser)` which looks like it should do the trick, I’ll give it a try and report back
