Welcome to elastic-bundle
Register and Configure elastic Bundle
For a Register elastic-bundle add elastic: true in config framework
./config/config.js
module.exports = {
system: {
elastic: true
}
}
Override elastic-bundle configuration your bundle
./app/config/config.js
"elastic-bundle": {
elasticsearch: {
globalHostsOptions: {
protocol: "http"
},
globalOptions: {
ssl: {
}
},
connections: {
main: {
hosts: [{
host: "192.168.100.181",
port: 9200
}],
sniffOnStart: true,
sniffInterval: 5000
}
}
}
}
Example to use :
./controller/defaultController.js
module.exports = class defaultController extends nodefony.controller {
constructor(container, context) {
super(container, context);
this.client = this.get("elastic").getClient("main");
}
health(params = {}) {
return this.client.cluster.health(params);
}
create() {
return this.client.indices.create({
index: 'nodefony'
});
}
ping() {
return this.client.ping({
requestTimeout: 30000,
});
}
indexAction() {
return this.ping()
.then(this.health.bind(this))
.then((ele) => {
return this.render("cci-bundle::index.html.twig", {
name: `Elastic Ping : ${ele}`
}).catch((e) => {
throw e;
});
}).catch((e) => {
throw e;
});
}
};
Authors
License