Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 未找到./node_modules/@elastic/elasticsearch/lib/Connection.js模块中的错误:错误:Can';t解决';http';_Angular_Typescript_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Angular6 - Fatal编程技术网 elasticsearch,angular6,Angular,Typescript,elasticsearch,Angular6" /> elasticsearch,angular6,Angular,Typescript,elasticsearch,Angular6" />

Angular 未找到./node_modules/@elastic/elasticsearch/lib/Connection.js模块中的错误:错误:Can';t解决';http';

Angular 未找到./node_modules/@elastic/elasticsearch/lib/Connection.js模块中的错误:错误:Can';t解决';http';,angular,typescript,elasticsearch,angular6,Angular,Typescript,elasticsearch,Angular6,我正在从事angular 6项目,我在服务器上将elasticsearch的版本从6更新为7,在将旧API的代码更改为使用新API后,出现了这些错误,有人知道如何更正吗 angular应用程序是在visual studio代码上开发的,elasticsearch是在linux服务器上开发的 import { Injectable } from '@angular/core'; // import { Clientex } from 'elasticsearch-browser'; import

我正在从事angular 6项目,我在服务器上将elasticsearch的版本从6更新为7,在将旧API的代码更改为使用新API后,出现了这些错误,有人知道如何更正吗

angular应用程序是在visual studio代码上开发的,elasticsearch是在linux服务器上开发的

import { Injectable } from '@angular/core';
// import { Clientex } from 'elasticsearch-browser';
import { Client } from '@elastic/elasticsearch';
// import * as elasticsearch from 'elasticsearch-browser';
// import { concatMapTo } from 'rxjs/operators';
// import { stringify } from '@angular/core/src/render3/util';


@Injectable({
  providedIn: 'root'
})

export class ElasticsearchService {

  private client: Client;
  // private clientex: Clientex;

  constructor() {
    if (!this.client) {
      this.connect();
    }
  }

  private connect() {
    /*this.client = new Client(
      {node: 'http://localhost:9200'}
    );*/
    this.client = new Client();
  }

  isAvailable(): Promise<any> {
    return this.client.ping({
    });
  }


  // tslint:disable-next-line:member-ordering
  private queryalldocs = {
    'query': {
      'match_all': {}
    }
  };

  getAllDocuments(_index, _type): any {
    this.client.search({
      index: _index,
      body: this.queryalldocs
    }, {
      ignore: [404]
    }, (err, { body, statusCode, headers, warnings }) => {
      if (err) { console.log(err); }
    });
}

  getAllDocumentsByKey(_index, _type, campo, valor) {
    const string = 'let match = {' + campo + ':' + valor + '}';
    return this.client.search({
      index: _index,
      type: _type,
      body: {
           // tslint:disable-next-line:no-shadowed-variable
           eval(string) {}
      }
    });
  }

  createDocument(value: any) {
    // return this.client.index(value);
    this.client.create(value);
  }

}
从'@angular/core'导入{Injectable};
//从“elasticsearch浏览器”导入{Clientex};
从'@elastic/elasticsearch'导入{Client};
//从“elasticsearch浏览器”导入*作为elasticsearch;
//从“rxjs/operators”导入{concatMapTo};
//从'@angular/core/src/render3/util'导入{stringify};
@注射的({
providedIn:'根'
})
导出类ElasticsearchService{
私人客户:客户;
//私人客户:客户;
构造函数(){
如果(!this.client){
这个.connect();
}
}
专用连接(){
/*this.client=新客户端(
{节点:'http://localhost:9200'}
);*/
this.client=新客户端();
}
可利用的:承诺{
返回此.client.ping({
});
}
//tslint:禁用下一行:成员排序
专用查询地址={
“查询”:{
'匹配所有':{}
}
};
getAllDocuments(_索引,_类型):任意{
这个是.client.search({
索引:_索引,
正文:this.queryaldocs
}, {
忽略:[404]
},(错误,{body,statusCode,header,warnings})=>{
if(err){console.log(err);}
});
}
getAllDocumentsByKey(_索引,_类型,campo,valor){
常量字符串='let match={'+campo+':'+valor+'}';
返回this.client.search({
索引:_索引,
类型:_类型,
正文:{
//tslint:禁用下一行:无阴影变量
求值(字符串){}
}
});
}
createDocument(值:任意){
//返回此.client.index(值);
这个。客户。创造(价值);
}
}
错误:

./node_modules/@elastic/elasticsearch/lib/Connection.js中出错 未找到模块:错误:无法解析中的“http” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node_modules@elastic\elasticsearch\lib'

./node_modules/@elastic/elasticsearch/lib/Connection.js中出错 未找到模块:错误:无法解析中的“https” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node_modules@elastic\elasticsearch\lib'

./node_modules/@elastic/elasticsearch/lib/Transport.js模块中出错 未找到:错误:无法解析中的“os” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node_modules@elastic\elasticsearch\lib'

未找到./node_modules/decompress response/index.js模块中的错误: 错误:无法解析中的“流” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node\u modules\decompresse response'

./node_modules/@elastic/elasticsearch/lib/Transport.js模块中出错 未找到:错误:无法在中解析“zlib” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node_modules@elastic\elasticsearch\lib'

未找到./node_modules/decompress response/index.js模块中的错误: 错误:无法在中解析“zlib” 'C:\Users\ICARO\Desktop\projetos\pastas\xtr social\node\u modules\decompresse response'


我相信您需要安装elasticsearch浏览器,然后:

import { Client } from 'elasticsearch-browser';

根据elasticsearch文档(),所有浏览器客户端都通过elasticsearch浏览器npm包进行处理:

不再支持浏览器,因为它将通过另一个模块@elastic/elasticsearch browser分发。此模块仅适用于Node.js


elasticsearch浏览器是elasticsearch版本6 API,这个新版本改变了从“@elastic/elasticsearch”导入
angular import{Client}的方式