loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
79 stars 56 forks source link

id change during get query #34

Closed kwiky closed 8 years ago

kwiky commented 8 years ago

When i call this endpoint : http://host:port/api/models/20160204161716631962

Loopback trace this :

-> POST http://host:port/api/model/_search?size=20&from=0
{
  "sort": [
    "id"
  ],
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "_id": "20160204161716634000"
          }
        }
      ]
    }
  }
}
<- 200
{
  "took": 10,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 0,
    "max_score": null,
    "hits": []
  }
}

Why did my id change during the query ? 20160204161716631962 => 20160204161716634000

kwiky commented 8 years ago

This is due to this : https://github.com/strongloop/loopback/issues/2042#issuecomment-180268956

I fixed my issue by forcing id to string by adding a letter before my long interger ids (ex : "i20160204161716634000")

pulkitsinghal commented 8 years ago

@kwiky - thanks for raising this and super thanks for finding the culprit+workaround!