I have a couple of things i don't understand.
1 I am trying to create a connection to elasticsearch so that i can access a specific index and then i can add data to it via a form.
my index.js looks like this since i read that you need to create a server and then communicate with elastic search
import exampleRoute from './server/routes/example';
export default function (kibana) {
  return new kibana.Plugin({
    require: ['elasticsearch'],
    name: 'article',
    uiExports: {
      app: {
        title: 'Article',
        description: 'lists articles in Kibana',
        main: 'plugins/article/app'
      },
    },
    init(server, options) {
      // Add server routes and initialize the plugin here
      exampleRoute(server);
      server.route({
        path: '/api/article/index/{name}',
        method: 'GET',
        handler(req, reply) {
          server.plugins.elasticsearch.callWithRequest(req, 'cluster.state', {
            metric: 'metadata',
            index: req.params.name
          }).then(function (response) {
            reply(response.metadata.indices[req.params.name]);
          });
        }
      });
    }
  });
};
then in my app.js i need to know how i would write my controller to access and modify my index in elasticsearch since i dont know what methods are available to help pass form data to elasticsearch.
Before i tried using a different method to access the index and it failed
app.js looked like this
uiModules
.get('app/testcloud', [])
.controller('testcloudHelloWorld', function ($scope, $route, $interval) {
  $scope.title = 'Testcloud';
  $scope.description = 'tags test';
  const currentTime = moment($route.current.locals.currentTime);
  $scope.currentTime = currentTime.format('HH:mm:ss');
  const unsubscribe = $interval(function () {
    $scope.currentTime = currentTime.add(1, 'second').format('HH:mm:ss');
  }, 1000);
  $scope.$watch('$destroy', unsubscribe);
});
uiModules
.get('app/testcloud', [])
.controller('dataCtrl', ['$scope','searchService',function($scope, searchService){
  $scope.results = {
    documents: []
  };
  searchService.search().then(function(es_return){
    scope.results.documents = es_return;
    console.log(es_return)
  })
  $scope.title = 'World';
  $scope.description = 'howdy';
  $scope.submit = function() {
    $scope.greeting = 'Hello ' + $scope.title + '!'+ $scope.description +'!';
  };
}]);
uiModules
.get('app/testcloud', [])
.service('searchService', ['$q','esFactory', function($q, esFactory){
  var esClient = esFactory ({
    location: 'localhost:9200'
  });
  this.search = function() {
    var deferred = $q.defer();
    esClient.search({
      index: 'article',
      body: {
        query: {
          match_all:{}
        }
      }
    }).then(function(es_return) {
      deferred.resolve(es_return);
    }, function(error) {
      deferred.reject(error);
    });
    return deferred.promise;
  };
}]);
and my index.html
<div ng-controller="dataCtrl">
  <div class="results">
    <h1>Articles</h1>
    <ul>
      <li ng-repeat="news in results.documents">
        <strong>{{news.title}}</strong>
      </li>
    </ul>
  </div>
  <br>
  Id:
    <input type="text" ng-model="id">
  <br>
  Title:
    <input type="text" ng-model="title">
  <br>
  Description:
    <input type="textarea" ng-model="description">
    <button ng-click='submit()'>submit</button>
 
</div>