# Exists query on \_uid field gives incorrect result on Elasticsearch 6.0.0

**URL:** <https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797>\
**Category:** Elasticsearch\
**Created:** [July 5, 2018, 8:50pm UTC](https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797 "2018-07-05T20:50:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyyanga](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@tonyyanga](https://discuss.elastic.co/u/tonyyanga)\
**Post date:** [July 5, 2018, 8:50pm UTC](https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797/1 "2018-07-05T20:50:28Z")

</div>

I think I am getting incorrect results when I run an Exists query on \_uid field on Elasticsearch 6.0.0. I believe the result is incorrect because I got different (and correct by common sense) results on Elasticsearch 6.2.4.

Here is what I did:

```
PUT /test_schema_1
{
  "settings":{
  	"analysis": {
      "char_filter": {
        "quote": {
          "type": "mapping",
          "mappings": [
            "« => \"",
            "» => \""
          ]
        }
      },
      "normalizer": {
        "my_normalizer": {
          "type": "custom",
          "char_filter": ["quote"],
          "filter": ["lowercase"]
        }
      }
    }
  },
    "index":{
      "number_of_shards":1,
      "number_of_replicas":0
    }
  }
}

PUT /test_schema_1/_mapping/test_table_1

{"test_table_1":{"properties":{"business_id":{"type":"text"},"full_address":{"type":"text"},"city":{"type":"keyword"},"city_analyzed":{"type":"text"},"state":{"type":"keyword"},"state_analyzed":{"type":"text"},"review_count":{"type":"integer"},"stars":{"type":"float"},"location_field":{"type":"geo_point"},"test_map":{"type":"nested"},"name":{"type":"text"},"open":{"type":"boolean"},"datefield":{"type":"date"}}}}

POST /_bulk?refresh=true

{ "index" : { "_index" : "test_schema_1", "_type" : "test_table_1" } }
{"business_id":"12345","full_address":"12345 A Street, Cambridge, MA","city":"Cambridge","city_analyzed":"Cambridge","state":"MA","state_analyzed":"MA","review_count":11,"stars":4.5,"location_field":[{"lat":11,"lon":11},{"lat":-11,"lon":-11}],"test_map":{"lat":11,"lon":11},"name":"Store in Cambridge","open":true,"datefield":"2014-02-10T10:50:42.000"}
{ "index" : { "_index" : "test_schema_1", "_type" : "test_table_1" } }
{"business_id":"abcde","full_address":"987 B Street, San Francisco, CA","city":"San Francisco","city_analyzed":"San Francisco","state":"CA","state_analyzed":"CA","review_count":22,"stars":3.5,"location_field":[{"lat":22,"lon":22},{"lat":-22,"lon":-22}],"test_map":{"lat":22,"lon":22},"name":"Store in San Francisco","open":true,"datefield":"2014-02-11T10:50:42.000"}
{ "index" : { "_index" : "test_schema_1", "_type" : "test_table_1" } }
{"business_id":"7890","full_address":"987 B Street, San Diego, CA","city":"San Diego","city_analyzed":"San Diego","state":"CA","state_analyzed":"CA","review_count":33,"stars":5.0,"location_field":[{"lat":33,"lon":33},{"lat":-33,"lon":-33}],"test_map":{"lat":33,"lon":33},"name":"Store in San Diego","open":false,"datefield":"2014-02-12T10:50:42.000"}
{ "index" : { "_index" : "test_schema_1", "_type" : "test_table_1" } }
{"business_id":"12345","full_address":"12345 A Street, Cambridge, MA","city":"Cambridge","city_analyzed":"Cambridge","state":"MA","state_analyzed":"MA","review_count":11,"stars":4.5,"location_field":[{"lat":44,"lon":44},{"lat":-44,"lon":-44}],"test_map":{"lat":44,"lon":44},"name":"Same store in Cambridge","open":true,"datefield":"2014-02-11T10:50:42.000"}
{ "index" : { "_index" : "test_schema_1", "_type" : "test_table_1" } }
{"business_id":"xyz","full_address":"12345 C Avenue, San Francisco, CA","city":"San Francisco","city_analyzed":"San Francisco","state":"CA","state_analyzed":"CA","review_count":1,"stars":1,"location_field":[{"lat":55,"lon":55},{"lat":-55,"lon":-55}],"test_map":{"lat":55,"lon":55},"name":"New store in San Francisco","open":false,"datefield":"2014-02-10T10:50:42.000"}

```

Query:

```
POST /test_schema_1/test_table_1/_search?scroll=300000ms

{
  "from" : 0,
  "size" : 1,
  "query" : {
    "bool" : {
      "should" : [
        {
          "bool" : {
            "must" : [
              {
                "exists" : {
                  "field" : "_uid",
                  "boost" : 1.0
                }
              }
            ],
            "disable_coord" : false,
            "adjust_pure_negative" : true,
            "boost" : 1.0
          }
        }
      ],
      "disable_coord" : false,
      "adjust_pure_negative" : true,
      "boost" : 1.0
    }
  }
}

```

I got 0 hits on Elasticsearch 6.0.0, which suggests no field has valid \_uid fields. However I got 5 hits on Elasticsearch 6.2.4.

Is this a known bug? Or is this behavior documented somewhere that I haven't found?

Thank you!

---

<div class="post-metadata">

**Author:** ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)\
**Post date:** [July 5, 2018, 11:29pm UTC](https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797/2 "2018-07-05T23:29:59Z")

</div>

Do you mean to write `_id` instead of `_uid`?

---

<div class="post-metadata">

**Author:** ![tonyyanga](https://avatars.discourse-cdn.com/v4/letter/t/46a35a/32.png) [@tonyyanga](https://discuss.elastic.co/u/tonyyanga)\
**Post date:** [July 5, 2018, 11:44pm UTC](https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797/3 "2018-07-05T23:44:42Z")

</div>

I mean to use \_uid, though I understand starting from ES 6, \_uid is just a view of \_id.

---

<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:** [August 2, 2018, 11:44pm UTC](https://discuss.elastic.co/t/exists-query-on-uid-field-gives-incorrect-result-on-elasticsearch-6-0-0/138797/4 "2018-08-02T23:44:44Z")

</div>

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