Loading data from kibana app

Hello guys,

I am developing a Kibana application and I need to insert data into Elasticsearch using a Form.
For example, I would like to add an user.

index.html:

<div class="container">
  <div class="row">
    <div class="col-12-sm" ng-controller="userController as controller">
      <h1>Sign In</h1><hr/>
      <form>
        <div class="form-group">
          <div class="form-group col-md-6">
            <label for="inputEmail4">Email</label>
            <input type="email" ng-model="email" class="form-control" id="inputEmail4" placeholder="Email" required>
          </div>
          <div class="form-group col-md-6">
            <label for="inputPassword4">Password</label>
            <input type="password" ng-model="password" class="form-control" id="inputPassword4" placeholder="Password" required>
          </div>
        </div>
        <div class="form-group">
          <div class="form-group col-md-6">
            <label for="inputAddress">Address 1</label>
            <input type="text" ng-model="address1" class="form-control" id="inputAddress" placeholder="1234 Main St" required>
          </div>
          <div class="form-group col-md-6">
            <label for="inputAddress2">Address 2</label>
            <input type="text" ng-model="address2" class="form-control" id="inputAddress2" placeholder="Apartment, studio, or floor" required>
          </div>
        </div>
        <div class="form-group">
          <div class="form-group col-md-6">
            <label for="inputCity">City</label>
            <input type="text" ng-model="city" class="form-control" id="inputCity" required>
          </div>
          <div class="form-group col-md-4">
            <label for="inputState">State</label>
            <select ng-model="state" id="inputState" class="form-control" required>
              <option selected>Choose...</option>
              <option> State 1 </option>
              <option> State 2 </option>
              <option> State 3 </option>
              <option> State 4 </option>
            </select>
          </div>
          <div class="form-group col-md-2">
            <label for="inputZip">Zip</label>
            <input type="text" ng-model="zip" class="form-control" id="inputZip" required>
          </div>
        </div>
        <button ng-click="controller.validate()" class="btn btn-primary"> Validate </button>
      </form>
    </div>
  </div>
</div>

And in my controller I prepare my object to insert it userController.js:

export function userController($http, $scope, $timeout, chrome, Notifier) {

// Call validate function
this.validate = () => {
let param = {
"email": $scope.email,
"password": $scope.password,
"address": $scope.address1 + $scope.address2 + $scope.city + $scope.state + $scope.zip
};
alert("Email:" +$scope.email+" \nPassword: "+$scope.password+" \nAddress: "+ $scope.address1 + $scope.address2 + $scope.city + $scope.state + $scope.zip);
// call kibana server API
};
}

How can I insert my object (param) into specific index in Elasticsearch ?

Best regards.

Hi,

you can inject the es service into your controller. That service is basically an instance of elasticsearch.js which you can use to call the bulk or index API to insert documents into elasticsearch.

Cheers,
Tim

Can you show me an example if I would use the index to put a document ? Thanks for advance ^^

Hi,

you can find an example on the usage in the documentation for the index API.

Cheers,
Tim

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