# Query elasticsearch from browser/webservice

**URL:** <https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697>\
**Category:** Elasticsearch\
**Created:** [April 26, 2018, 2:23pm UTC](https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697 "2018-04-26T14:23:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Martijn](https://discuss.elastic.co/u/Martijn)\
**Post date:** [April 26, 2018, 2:23pm UTC](https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697/1 "2018-04-26T14:23:27Z")

</div>

Hello,

I've recently upgraded my Elasticsearch environment from 2.4 to 6.2. The old ES 2.4 environment was sometimes used as a datasource by ETL processes. The ETL process involved a simple API call, which looks like this:

[http://localhost:9200/filebeat-\*/\_search/?source=](http://localhost:9200/filebeat-*/_search/?source=)

This request also worked from by pasting it in the browser, and would return the relevant data as Lucene.

It seems that in version 6.2 the api has changed and these calls are no longer working. I've tried a simple "match all" query from the browser, but it gives me the following error:

call in browser:

[http://localhost:9200/filebeat-\*/\_search/?source={"query":{"match\_all":{}](http://localhost:9200/filebeat-*/_search/?source=%7B%22query%22:%7B%22match_all%22:%7B%7D)}}

response:

{"error":{"root\_cause":[{"type":"illegal\_state\_exception","reason":"source and source\_content\_type parameters are required"}],"type":"illegal\_state\_exception","reason":"source and source\_content\_type parameters are required"},"status":500}

I've also tried it following the new documentation:

[http://localhost:9200/filebeat-\*/\_search/?q={"query":{"match\_all":{}](http://localhost:9200/filebeat-*/_search/?q=%7B%22query%22:%7B%22match_all%22:%7B%7D)}}

{"error":{"root\_cause":[{"type":"query\_shard\_exception","reason":"Failed to parse query [{"query":{"match\_all"

Has anyone managed to get the query working (with lucene in the api call)?

---

<div class="post-metadata">

**Author:** ![DennisM](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dennism/32/30512_2.png) [@DennisM](https://discuss.elastic.co/u/DennisM)\
**Post date:** [April 26, 2018, 2:29pm UTC](https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697/2 "2018-04-26T14:29:38Z")

</div>

You don't use lucene as part of the url; just pretty basic syntax like:

```
http://localhost:9200/ _search?q=field:value

```

If you want to use lucene you need to do a POST and include your query as the body of the request, as in:

```
{
"query": {
   "multi_match": {
   		"query": "Error",
   		"fields": ["theType"]
	}
}
}
```

---

<div class="post-metadata">

**Author:** ![Martijn](https://avatars.discourse-cdn.com/v4/letter/m/dbc845/32.png) [@Martijn](https://discuss.elastic.co/u/Martijn)\
**Post date:** [April 28, 2018, 6:43pm UTC](https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697/3 "2018-04-28T18:43:37Z")

</div>

Hi Dennis,

Thank you for the reply. I will look into sending a POST insetad of a GET.

I did find out how to nest the lucene query in the URL. All I had to do was add the source\_content\_type variable, but the URL does not work with an Elasticsearch instance with basic authentication ☹.

For those interested, the URL would look like this:

[http://localhost:9200/filebeat-\*/\_search/](http://localhost:9200/filebeat-*/_search/)? **source\_content\_type=application/json** &source={"query":{"match\_all":{}}}

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 26, 2018, 6:43pm UTC](https://discuss.elastic.co/t/query-elasticsearch-from-browser-webservice/129697/4 "2018-05-26T18:43:37Z")

</div>

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