Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch - search_type as a body parameter

I am a bit fighting with specifying search_type as a body parameter. As a query parameter that is just fine and works but haven't found single example in manual where it is specified as a query parameter.

POST /index/type/_search
{
 "search_type": {"query_then_fetch"}, 
 "explain": false,
     "query" : { 
         "query_string": {
            "default_field": "adress.city",
            "query": "London"
         }
     }
}

Any hints?

Thx

like image 852
jaksky Avatar asked Dec 23 '14 11:12

jaksky


1 Answers

putting the search type in the body is not supported, from the documentation:

The type can be configured by setting the search_type parameter in the query string.

So your query should look like this:

curl -XGET http://localhost:9200/index/type/_search?search_type=query_then_fetch -d '
{
 "explain": false,
     "query" : { 
         "query_string": {
            "default_field": "adress.city",
            "query": "London"
         }
     }
}'
like image 173
Olly Cruickshank Avatar answered Sep 20 '22 21:09

Olly Cruickshank