Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why I'm getting unrecognized parameter: [query]

I'm using es 6.8 and elasticvue (as firefox plugin)

I created an index:

put /q1
 {
    "mappings": {
        "my_type": {
            "properties": {
                "name" : {"type" : "text"},
                "last" : {"type": "text"},
                "age" : {"type": "integer"}
            }
        }
    }
 }

and put some data:

post /q1/my_type
 {

        "name" : "miki",
        "last" : "elk",
        "age" : "35"

 }

When I try to search:

get /q1/_search
{
    "query" : {
        "term" : { "name" : "miki" }
    }
}

I'm getting error:

"error": {
    "root_cause": [
        {
            "type": "illegal_argument_exception",
            "reason": "request [/q1/_search] contains unrecognized parameter: [query]"
        }
    ],
    "type": "illegal_argument_exception",
    "reason": "request [/q1/_search] contains unrecognized parameter: [query]"
},
"status": 400

What is wrong and how can I fix it ?

like image 944
user3668129 Avatar asked Sep 05 '25 03:09

user3668129


1 Answers

This error might happen when a wrong GET parameter is sent to the server. Assuming that you are using elasticvue firefox plugin, and you are using query tab:

You can change GET method to POST method and it should work fine. It seems like elasticvue have some problem in using GET method here. Looking at the developer network tool in firefox the request will be sent to the following URL:

http://localhost:9200/q1/_search?query=%5Bobject%20Object%5D

Which is obviously wrong and it sends your query as a GET parameter named query! There is no such GET parameter and it should send the query as body of the request not as its parameter. Using POST is an alternative and is allowed by Elasticsearch API. You can use kibana as an official and powerful tool as well.

like image 126
maanijou Avatar answered Sep 07 '25 19:09

maanijou