bitemyapp / bloodhound

Haskell Elasticsearch client and query DSL
bitemyapp.com
BSD 3-Clause "New" or "Revised" License
424 stars 118 forks source link

[WIP] Elasticsearch 7 support #263

Closed mbg closed 4 years ago

mbg commented 5 years ago

According to https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html, mapping names/types are being removed from Elasticsearch. I am running Elasticsearch 7.3 which rejects requests made with the current implementation of e.g. indexDocument:

Response {
  responseStatus = Status {statusCode = 400, statusMessage = "Bad Request"}, 
  responseVersion = HTTP/1.1, 
  responseHeaders = [
    ("Warning","299 Elasticsearch-7.3.0-de777fa \"[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id}).\""),
    ("content-type","application/json; charset=UTF-8"),
    ("content-encoding","gzip"),
    ("content-length","183")], 
  responseBody = "{\"error\":{\"root_cause\":[{\"type\":\"illegal_argument_exception\",\"reason\":\"Rejecting mapping update to [index-name] as the final mapping would have more than 1 type: [_doc, mapping-name]\"}],\"type\":\"illegal_argument_exception\",\"reason\":\"Rejecting mapping update to [index-name] as the final mapping would have more than 1 type: [_doc, mapping-name]\"},\"status\":400}", 
  responseCookieJar = CJ {expose = []}, 
  responseClose' = ResponseClose}

Furthermore, Elasticsearch seems to expect POST requests instead of a PUT requests now.

This PR changes indexDocument so that it works with the current version of Elasticsearch. If this is a welcome change, I can look into updating the other parts of the library.