开发者

Search ElasticSearch via GET using JSON

开发者 https://www.devze.com 2023-03-28 07:16 出处:网络
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, i

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开发者_JAVA技巧 as just passing the content after the ? but nothing seems to work. Anyone have any ideas? Or am I just out of luck?


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消