I am working on an angular 6 project and I updated the version of elasticsearch from 6 to 7 on the server, after changing the code of the old API to use the new one, these errors occurred, does anyone have any idea how to correct?
The angular application is made on visual studio code and elasticsearch is on a linux server.
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);
}
}
ERRORS:
ERROR in ./node_modules/@elastic/elasticsearch/lib/Connection.js Module not found: Error: Can't resolve 'http' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules@elastic\elasticsearch\lib'
ERROR in ./node_modules/@elastic/elasticsearch/lib/Connection.js Module not found: Error: Can't resolve 'https' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules@elastic\elasticsearch\lib'
ERROR in ./node_modules/@elastic/elasticsearch/lib/Transport.js Module not found: Error: Can't resolve 'os' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules@elastic\elasticsearch\lib'
ERROR in ./node_modules/decompress-response/index.js Module not found: Error: Can't resolve 'stream' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules\decompress-response'
ERROR in ./node_modules/@elastic/elasticsearch/lib/Transport.js Module not found: Error: Can't resolve 'zlib' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules@elastic\elasticsearch\lib'
ERROR in ./node_modules/decompress-response/index.js Module not found: Error: Can't resolve 'zlib' in 'C:\Users\ICARO\Desktop\projetos\pastas\xtr-social\node_modules\decompress-response'