# Query written in dev console fails executing on Discovery page

**URL:** <https://discuss.elastic.co/t/query-written-in-dev-console-fails-executing-on-discovery-page/232245>\
**Category:** Kibana\
**Created:** [May 12, 2020, 2:37pm UTC](https://discuss.elastic.co/t/query-written-in-dev-console-fails-executing-on-discovery-page/232245 "2020-05-12T14:37:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jon\_Florentine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jon_florentine/32/68162_2.png) [@Jon\_Florentine](https://discuss.elastic.co/u/Jon_Florentine)\
**Post date:** [May 12, 2020, 2:37pm UTC](https://discuss.elastic.co/t/query-written-in-dev-console-fails-executing-on-discovery-page/232245/1 "2020-05-12T14:37:21Z")

</div>

Hi all,

I have written this KQL query in dev console, and it runs fine.

```auto
GET _search
{
  "query": {
    "bool" : {
        "must" : [
          {"exists": {"field": "kubernetes.deployment.replicas"}}
          ,
          {"range": {"@timestamp":{
            "gte": "now-30s"
          }}
          }
        ]
      }
    }
  }

```

I want to save it for reuse later, but then I figure out that it cannot be saved from the dev console. By googling I read from people that to save it , I need to copy the query onto the query input field on the discovery page, and from there , it can be saved.  
That's what I am doing, but as soon as it is copped, it executes, and at best it stop with an error, at worst, it runs forever freezing my Kibana session.  
Note that I do not copy over on discovery the GET\_Search {"query": {}} enveloppe, but only its content:

```auto
    "bool" : {
        "must" : [
          {"exists": {"field": "kubernetes.deployment.replicas"}}          
          ,
          {"range": {"@timestamp":{
            "gte": "now-30s"
          }}
          }
        ]
      }

```

what works in discovery is just:  
kubernetes.deployment.replicas.available : \*  
But i need the complex one as it need to be further developed.

Did i missed something ?  
Any suggestion, somebody solved that ?  
Thanks  
Jean

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [May 12, 2020, 8:36pm UTC](https://discuss.elastic.co/t/query-written-in-dev-console-fails-executing-on-discovery-page/232245/2 "2020-05-12T20:36:39Z")

</div>

there might be some naming-mishap happening here.

that query you showed and use in dev-tools is a raw Elastiscearch query-DSL statement.

If you try and copy-paste this into the query-bar, it's not going to work, because it's not a KQL-query. KQL is more of a syntax to write filters.

What you can do is use this in a filter-pill.

In Discover, click "Add filter" .

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/a/7a5012beaf82861159e855fb88da0176c5655f01.png)

and then use the "exists" setting

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/7/5787acd4500ec209dd130e211d5402303ed733a4.png)

Note that the "range"-part is just a time-based expression ,so you could use the global time-selector (top right) for that

---

<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:** [June 9, 2020, 8:36pm UTC](https://discuss.elastic.co/t/query-written-in-dev-console-fails-executing-on-discovery-page/232245/3 "2020-06-09T20:36:49Z")

</div>

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