Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search ElasticSearch via GET using JSON

Anyone know of a way to send a JSON query to an ElasticSearch server via HTTP GET? I know you can POST the JSON content to _search, but POST is not available because this is cross-domain. For example, if my query looks like this:

{
    "query": {
        "query_string": {
            "fields": ["name", "description"],
            "query": "Elastic Search"
        }
    }
}

Which I would convert to something like:

{"query":{"query_string":{"fields":["name","description"],"query":"Elastic Search"}}}

Is there a way to GET server:9200/index/type/_search?content=stringifiedquery or something similar? I've tried q= and content= as well as just passing the content after the ? but nothing seems to work. Anyone have any ideas? Or am I just out of luck?

like image 511
inxilpro Avatar asked Feb 03 '23 15:02

inxilpro


1 Answers

You can use the source query string parameter to send what would normally be the post body.

See the bottom of this page: http://www.elasticsearch.org/guide/reference/api/

like image 58
DrTech Avatar answered Feb 05 '23 04:02

DrTech