Missing field in querytring syntax

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.

Hi @Trynar,

The missing query has been replaced by the exists query with negation in 5.0 (see docs).

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

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:

 {
   "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

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. :slight_smile:

Hi @Trynar,

great that it works now! :slight_smile:

Daniel

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