# Elasticsearch and AngularJS Client no result

**URL:** <https://discuss.elastic.co/t/elasticsearch-and-angularjs-client-no-result/48106>\
**Category:** Elasticsearch\
**Created:** [April 21, 2016, 10:06pm UTC](https://discuss.elastic.co/t/elasticsearch-and-angularjs-client-no-result/48106 "2016-04-21T22:06:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hamdi-charef](https://avatars.discourse-cdn.com/v4/letter/h/898d66/32.png) [@hamdi-charef](https://discuss.elastic.co/u/hamdi-charef)\
**Post date:** [April 21, 2016, 10:06pm UTC](https://discuss.elastic.co/t/elasticsearch-and-angularjs-client-no-result/48106/1 "2016-04-21T22:06:04Z")

</div>

I'm trying to plot data stored in Elasticsearch using AngularJS client

This is my html and js code.  
I have no idea about the wrong thing:  
`es_connect.js`

```
// We define an EsConnector module that depends on the elasticsearch module

var EsConnector = angular.module('EsConnector', ['elasticsearch']);

EsConnector.service('es', function (esFactory) {
    return esFactory({ host: 'http://localhost:9200' });
});

// We define an Angular controller that returns the server health
// Inputs: $scope and the 'es' service

EsConnector.controller('ServerHealthController', function($scope, es) {

    es.cluster.health(function (err, resp) {
        if (err) {
            $scope.data = err.message;
        } else {
            $scope.data = resp;
        }
    });
});

// We define an Angular controller that returns query results,
// Inputs: $scope and the 'es' service

EsConnector.controller('QueryController', function($scope, es) {
// search for documents
    es.search({
    index: 'boxes',
    type: 'boxid',
    body: {
    "query": {
        "bool": {
            "must": [
                {
                    "term": {
                        "boxid": ""
                    }
                }
            ],
            "must_not": [],
            "should": []
        }
    }
    }
}).then(function (body) {
    var $scope.body = body.hits.hits;
    return $scope.body;
})
});

```

**Index.html**

```
<!doctype html>
<html ng-app="EsConnector">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript" src="angular.js"></script>
    <script type="text/javascript" src="elasticsearch.angular.js"></script>
    <script type="text/javascript" src="es_connect.js"></script>

  </head>

  <body>

  <div ng-controller="QueryController">
    <table>
          <tr ng-repeat="item in hits">
          <td>{{item['_source']['name']}}</td></tr>
        </table>
    </div>

  <div ng-controller="QueryController">

    <li>Request took {{Response.took}} ms
    <li>Request matched {{Response.hits.total}} hits
    <p>Here is some information on the items returned:</p>
    <ul>
      <li ng-repeat="item in body.hits.hits">{{item._source.boxid}},{{item._source.shop.updated}}</li>
    </ul>
    </div>

    <br>
    Above this line ^^^ should be the results of a test search on the ElasticSearch server.
    </body>
</html>

```

my elasticsearch index is boxes and the index type is boxid.

---

<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:** [July 5, 2017, 10:57pm UTC](https://discuss.elastic.co/t/elasticsearch-and-angularjs-client-no-result/48106/2 "2017-07-05T22:57:09Z")

</div>


