# Missing field in querytring syntax

**URL:** <https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143>\
**Category:** Elasticsearch\
**Created:** [December 6, 2016, 9:03am UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143 "2016-12-06T09:03:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trynar](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Trynar](https://discuss.elastic.co/u/Trynar)\
**Post date:** [December 6, 2016, 9:03am UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143/1 "2016-12-06T09:03:02Z")

</div>

Hi,

First, sorry for my poor english, not my primary langage.

Then, this is my problem.

I used the _missing_ syntx in 2.4.1 and it works well, but now i cant make it work for 5.0.1

For exemple, i have 100 documents, 55 with an existing "color" field, 45 with not.

if my request is

```
{
  "size" : 50,
"_source":["color"],
  "query" : {
    "bool" : {
      "filter" : [
        {
          "query_string" : {
            "query" : " _exists_:color",
            "fields" : [],
            "use_dis_max" : true,
            "tie_breaker" : 0.0,
            "default_operator" : "or",
            "auto_generate_phrase_queries" : false,
            "max_determined_states" : 10000,
            "lowercase_expanded_terms" : true,
            "enable_position_increment" : true,
            "fuzziness" : "AUTO",
            "fuzzy_prefix_length" : 0,
            "fuzzy_max_expansions" : 50,
            "phrase_slop" : 0,
            "locale" : "und",
            "escape" : false,
            "boost" : 1.0
          }
        }
      ],
      "disable_coord" : false,
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  },
  "ext" : { }
}

```

I will see the 55 documents that i need.

But if my querystring is :  
`"query" : " _missing_:color"`

i will see 0 documents.

Am i using the wrong syntax ?  
How can i do this to work ?

Thanks in advance.

Trynar.

PS : for my use, i have to do it with querystring, i just let the simple example to be more understandeable, but i cant go without querystring for my use.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 6, 2016, 10:16am UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143/2 "2016-12-06T10:16:26Z")

</div>

Hi @Trynar,

The missing query has been replaced by the exists query with negation in 5.0 (see [docs](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-exists-query.html#_literal_missing_literal_query)).

Here is a complete example that works (tested with Elasticsearch 5.0.1)

```auto
DELETE /example

POST /example/people/1
{
    "first": "John",
    "last": "Smith",
    "birthday": "1990-01-01"
}

POST /example/people/2
{
    "first": "Lea",
    "last": "Smith"
}

GET /example/people/_search?q=NOT _exists_:birthday

```

This returns one hit as expected:

```auto
 {
   "took": 2,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "example",
            "_type": "people",
            "_id": "2",
            "_score": 1,
            "_source": {
               "first": "Lea",
               "last": "Smith"
            }
         }
      ]
   }
}

```

Daniel

---

<div class="post-metadata">

**Author:** ![Trynar](https://avatars.discourse-cdn.com/v4/letter/t/bcef8e/32.png) [@Trynar](https://discuss.elastic.co/u/Trynar)\
**Post date:** [December 6, 2016, 11:52am UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143/3 "2016-12-06T11:52:02Z")

</div>

Thanks, exactly what i was looking for to solve my issue.

transform my _missing_ in NOT _exists_ in my querystring do the job !

Problem solved. 🙂

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [December 6, 2016, 12:03pm UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143/4 "2016-12-06T12:03:18Z")

</div>

Hi @Trynar,

great that it works now! 🙂

Daniel

---

<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:** [January 3, 2017, 12:03pm UTC](https://discuss.elastic.co/t/missing-field-in-querytring-syntax/68143/5 "2017-01-03T12:03:29Z")

</div>

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