jprante / elasticsearch-langdetect

A plugin for language detection in Elasticsearch using Nakatani Shuyo's language detector
Apache License 2.0
251 stars 46 forks source link

REST API returns an application/yaml response #65

Open BastienL opened 7 years ago

BastienL commented 7 years ago

Not a big issue, but when the text starts with "---", the REST API responds with a yaml instead of a JSON:

curl -XPOST 'localhost:9200/_langdetect?pretty' -d '---This is a test' -i
HTTP/1.1 200 OK
Content-Type: application/yaml
Content-Length: 90

---
profile: "/langdetect/"
languages:
- language: "en"
  probability: 0.9999972283490304

You got to set the Content-Type to application/json to make it return a JSON response:

curl -XPOST 'localhost:9200/_langdetect?pretty' -d '---This is a test' -i -H "Content-Type: application/json"
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 122

{
  "profile" : "/langdetect/",
  "languages" : [ {
    "language" : "en",
    "probability" : 0.9999972283490304
  } ]
}

Maybe that should be mentioned in the documentation that setting the appropriate Content-Type is recommended?