0

I'm trying to use the _analyze api with text that looks like this:

--- some -- text ---

This request works as expected:

curl localhost:9200/my_index/_analyze -d '--'
{"tokens":[]}

However, this one fails:

curl localhost:9200/medical_documents/_analyze -d '---'
---
error:
  root_cause:
  - type: "illegal_argument_exception"
    reason: "Malforrmed content, must start with an object"
  type: "illegal_argument_exception"
   reason: "Malforrmed content, must start with an object"
status: 400

Considering the formatting of the response, i assume that elasticsearch tried to parse the request as yaml and failed.

If that is the case, how can i disable yml parsing, or _analyze a text that starts with --- ?

iCart
  • 2,179
  • 3
  • 27
  • 36

1 Answers1

1

The problem is not the yaml parser. The problem is that you are trying to create a type.
The following is incorrect
(will give you Malforrmed content, must start with an object error)
curl localhost:9200/my_index/medical_documents/_analyze -d '---'

This will give you no error, but is incorrect. Because it will tell elastic to create a new type.
curl localhost:9200/my_index/medical_documents/_analyze -d '{"analyzer" : "standard","text" : "this is a test"}'

Analyzers are created Index level. verify with:
curl -XGET 'localhost:9200/my_index/_settings'<br/>

So the proper way is: curl -XGET 'localhost:9200/my_index/_analyze' -d '{"analyzer" : "your_analyzer_name","text" : "----"}'
Previously need to create the analyzer.

Hosar
  • 5,163
  • 3
  • 26
  • 39