向 Elasticsearch 提交用户反馈数据

Submitting user feedback data to Elasticsearch

我正在尝试使用此 angular bootstrap feedback form 收集用户反馈数据并将信息索引到 Elasticsearch(使其可搜索)。

所以在我的 Elasticsearch searchService 中,我只是做了:

this.userSearchFeedback = function (userFeedbackForm) {
    esClient.index({
      index: 'searchfeedback-index1',
      type: 'general',
      opType: 'index',
      refresh: true,
      body: {
        fields: ['comments', 'email']
      }
    }).then(function(es_return) {
      console.log('success');
    }, function(error) {
      console.log('error');
    });
  };

userFeedbackForm 是表单的名称,如下所示:

    <div class="row">
    <div class="col-xs-12">
      <div class="alert alert-info" role="alert">
        We would love to hear your thoughts and suggestions on what we get right and wrong - it helps us improve our services to you. Your feedback is appreciated and helps us get better!
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-lg-6">
      <!-- DESCRIPTION -->
      <div class="form-group">
        <pre>Model: {{comments | json}}</pre>
        <label for="description_field" class="control-label">Comment:</label>
        <textarea class="form-control" placeholder="Please describe your issue or share your feedback!" name="comments" ng-model="comments" style="min-height: 165px;"></textarea>
      </div>
      <!-- /DESCRIPTION -->
      <!-- EMAIL -->
      <div class="form-group">
        <pre>Model: {{email | json}}</pre>
        <label for="email_field" class="control-label">Email:</label>
        <input type="text" class="form-control" placeholder="Email" name="email" ng-model="email" />
      </div>
      <!-- /EMAIL -->
    </div>

我已经为两个输入添加了 ng-models 并将它们添加到我的控制器中

//initialize feedback form
$scope.feedback = {
  comments: '',
  email: ''
};

该模块已经带有一个从 ng-click 表单模板调用的函数...

function submitButtonPressed(form) {
console.log("Submit button pressed");
console.log(form);
console.log($scope.feedback.comments);//added
console.log($scope.feedback.email);//added

这就是我卡住的地方。

我还需要对函数做些什么才能在我的 searchService 中调用 userSearchFeedback() 以便将表单数据索引到 ES?

经过以上发布的试验和错误。我决定看看是否还有其他可用的东西。还有is and its amazingly simple要执行。只需添加 url 提交即可!在短短几分钟内完成并运行(一旦我意识到我必须提供url)。

HTH 任何人。