在angular 2应用程序上使用elasticsearch摄取附件插件

zhte4eai  于 2021-06-15  发布在  ElasticSearch
关注(0)|答案(0)|浏览(185)

我尝试在angular 2应用程序中使用一些elasticsearch特性,比如上传pdf文件以提取数据并将其添加到elasticsearch服务。我使用的是elasticsearch npm包,当我尝试创建索引并向其中添加文档时,它可以正常工作,但我想使用插入附件插件将文件内容添加到我的服务中。
因此,将文档添加到索引的代码如下所示:

this.elastic.addToIndex({
        index: "testdocs",
        type: 'doc',
        id: this.id,
        body: {
          data : datos
        }
      }).then((result) => {
        console.log(result);
        alert('Success');
        this.id = this.id + 1;
      }, error => {
        alert('Fail :)');
        console.error(error);
      });

但是如何对摄取过程进行第一次put查询,在这里我必须将信息添加到管道中?我试着这样做:

this.elastic.addToIndex({
      index: "_ingest",
      type: 'pipeline',
      id: "attachment",
      body: {
        description : "Tipo " + this.file.type + " | " + this.file.name,
        processors : [
        {
          attachment : {
            field : "data",
            properties : [ "content", "title", "name", "author", "keywords", "date", "content_type", "content_length", "language"]
          }
        }
      ]
      }

[...]
但我得到的只是一个400的错误,像这样:

"type": "invalid_index_name_exception",
      "reason": "Invalid index name [_ingest], must not start with \u0027_\u0027, \u0027-\u0027, or \u0027+\u0027",
      "index_uuid": "_na_",
      "index": "_ingest"

有没有办法在angular 2中使用这个摄取插件?非常感谢:)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题