Why 404 occured when use es.search() in kibana6.x?

Ah I see, apologies I missed the second type definition. You'll likely want the query to look like this:

{
  "query": {
    "ids": {
      "type": "doc",
      "values": ["index-pattern:3851cd60-0450-11e8-8f86-9312c81e614d"] 
    }
  }
}
    query: {
      "ids": {
        "values" : ['index-pattern' + $scope.vis.indexPattern.id]
      }
    }