Exists query on _uid field gives incorrect result on Elasticsearch 6.0.0


(Tony Yang) #1

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!


(Kofi) #2

Do you mean to write _id instead of _uid?


(Tony Yang) #3

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


(system) #4

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