elasticsearch和angular js互通错误

时间:2017-08-28 00:17:48

标签: angularjs elasticsearch

嗨我想知道那个问题,所以我想问别人 所以请给我解决方案?

我制作了那张照片的html文件 但是当我打开这个html文件时,这个文件无效... 任何数据都没有显示

这个html文件中的问题是什么?enter image description here

<!doctype html>
<html ng-app="myApp">
<head>
     <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>

<div ng-controller="QueryController">
</div>

<script src="node_modules/angular/angular.js"></script>
<script src="node_modules/elasticsearch-browser/elasticsearch.angular.js"></script>

<script>
    var myApp = angular.module('myApp', ['elasticsearch']);

    // Create the es service from the esFactory
    myApp.service('es', function (esFactory) {
        return esFactory({ host: 'localhost:9200'});
    });

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

        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

    myApp.controller('QueryController', function($scope, es, esFactory) {

// search for documents
        es.search({
            index: 'epowersyst',
            type: 'logs',
            body: {
              query:
                {
                  match_all : {} }
                }

        }).then(function (response) {
            $scope.hits = response;
            console.log($scope.hits)
            alert("hits값 : " + response);
        });

    });
</script>
</body>
</html>

0 个答案:

没有答案