Error saying request body or source is required

So I am testing my analyzer after I created it successfully using -
{
"settings" : {
"analysis": {
"filter": {
"autocomplete_filter" : {
"type" : "edge_ngram",
"min_gram" : 1,
"max_gram" : 20
}
},
"analyzer": {
"autocomplete" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : [
"lowercase",
"autocomplete_filter"
]
}
}
}
}
}

After this I indexed the data in my index named "assessment_kit"

But When I am testing it using - curl -XGET "localhost:9200/assessment_kit/_analyze?analyzer=autocomplete&pretty" -H -d "Fro"

I am getting an error -

{
"error" : {
"root_cause" : [
{
"type" : "parse_exception",
"reason" : "request body or source parameter is required"
}
],
"type" : "parse_exception",
"reason" : "request body or source parameter is required"
},
"status" : 400
}
curl: (6) Could not resolve host: Fro

I should be able to get ngram for the same?

Your curl request is malformed. Try the following:

curl -XGET "http://localhost:9200/assessment_kit/_analyze?pretty" -H 'Content-Type: application/json' -d '{ "analyzer": "autocomplete", "text": "Fro" }'
1 Like

Somehow I have similar issue with getting the _analyze endpoint to work: See the example below, and the silent failure at the end (no output for the last command)

$~/code/esapp$ GET http://localhost:9200/awscatalog-ngram/_settings?pretty
{
  "awscatalog-ngram" : {
    "settings" : {
      "index" : {
        "number_of_shards" : "5",
        "provided_name" : "awscatalog-ngram",
        "creation_date" : "1537273886758",
        "analysis" : {
          "analyzer" : {
            "an_analyzer" : {
              "filter" : [
                "lowercase"
              ],
              "type" : "custom",
              "tokenizer" : "a_tokenizer"
            }
          },
          "tokenizer" : {
            "a_tokenizer" : {
              "token_chars" : [
                "letter",
                "digit"
              ],
              "min_gram" : "2",
              "type" : "edge_ngram",
              "max_gram" : "10"
            }
          }
        },
        "number_of_replicas" : "1",
        "uuid" : "U8UmxEIMSK659Bfa7n_k1g",
        "version" : {
          "created" : "6040099"
        }
      }
    }
  }
}
$~/code/esapp$ GET http://localhost:9200/awscatalog-ngram/_analyze?pretty -H 'Content-Type: application/json' -d '{ "analyzer": "an_analyzer", "text": "velociraptors are cool" }'
 $~/code/esapp$ 

What am I doing wrong?

Thanks in advance.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

Hi, the problem could be in this test command:

curl -XGET http://localhost:9200/awscatalog-ngram/_analyze?pretty -H 'Content-Type: application/json' -d '{ "analyzer": "an_analyzer", "text": "velociraptors are cool" }'

This sends a request that has a body payload, so it should use the POST method.