# Count endpoint of elasticsearch service results in HTTP 404

**URL:** <https://discuss.elastic.co/t/count-endpoint-of-elasticsearch-service-results-in-http-404/219564>\
**Category:** Kibana\
**Created:** [February 17, 2020, 5:42am UTC](https://discuss.elastic.co/t/count-endpoint-of-elasticsearch-service-results-in-http-404/219564 "2020-02-17T05:42:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajmcmiddlin](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@ajmcmiddlin](https://discuss.elastic.co/u/ajmcmiddlin)\
**Post date:** [February 17, 2020, 5:42am UTC](https://discuss.elastic.co/t/count-endpoint-of-elasticsearch-service-results-in-http-404/219564/1 "2020-02-17T05:42:17Z")

</div>

I'm attempting to use the `elasticsearch` service within my Kibana 7.4 plugin. The plugin works fine when using the search endpoint (I get a HTTP 200 response and search results), however the count endpoint results in a HTTP 404 (Not Found).

As I understand it, Kibana proxies searches to the elasticsearch cluster. Given I'm running a local dev server for Kibana 7.4 my searches use URLs like the following.

```
http://localhost:5601/fhv/s/<space name>/elasticsearch/my-index/_count
http://localhost:5601/fhv/s/<space name>/elasticsearch/my-index/_search

```

If I manually `curl` the count endpoint using one of the nodes in my elasticsearch cluster, I get a response including the count of documents matching my query (as expected).

Some sample code to help demonstrate what I'm doing in my Kibana plugin:

```javascript
import {
  EuiSearchBar,
  Query,
} from '@elastic/eui';

// onChange handler for EuiSearchBar
euiSearchBarChanged({query}: {query: Query}) {
  /* es is my handle to the elasticsearch client instance.
   * Passed in as a React property to my plugin's component.
   * app.js lists this as a dependency for the Angular RootController --- e.g.
   * `RootController($scope, $element, es) { ... }`
   */
  const {es} = this.props;
  const esQuery = Query.toESQuery(query);
  const params = {
    index: 'my-index',
    body: { query: esQuery },
  };

  // Error handler used and specifies a 404.
  es.count(params).then(
    r => console.log('count results', r),
    e => console.log('count error', e)
  );

  // Logs search results as expected
  es.search<MyDocType>(params).then(
    r => console.log('search results', r),
    e => console.log('search error', e)
  );
}

```

---

<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:** [March 16, 2020, 5:42am UTC](https://discuss.elastic.co/t/count-endpoint-of-elasticsearch-service-results-in-http-404/219564/2 "2020-03-16T05:42:20Z")

</div>

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