I want to built a application and a api which will mainly retrieve a resource, Now I have heard a lot about Nodejs
and ElasticSearch
and I know little bit Nodejs and Express framework. But I don't know how will I integrated ElasticSearch with Express framework.
Elasticsearch lets you search through vast amounts of data, whether you're implementing real-time search experiences or doing in-depth data analysis. In this tutorial, you'll learn how to integrate Elasticsearch into your Node. js app.
Middleware frameworks, like Express. js, are suitable for small and medium projects. If you are going to develop a large project that will be supported by a large team of developers, Express. js is not the best choice.
Advantages Of Express JS It makes configuration of the Express. js apps and customization your web development easily. js is an excellent framework that helps developers to define the routing of web-apps. It helps template engine integrations, especially with engines like Jade, Vash, and EJS.
npm install elasticsearch --save
To use that module, simply create a client instance
var elasticsearch = require('elasticsearch');
var client = elasticsearch.Client({
host: 'localhost:9200'
});
client.search({
index: 'books',
type: 'book',
body: {
query: {
multi_match: {
query: 'express js',
fields: ['title', 'description']
}
}
}
}).then(function(response) {
var hits = response.hits.hits;
}).catch(function (error) {
console.trace(error.message);
});
Helpfull Link https://blog.raananweber.com/2015/11/24/simple-autocomplete-with-elasticsearch-and-node-js/
First, of course you need a Elasticsearch instance running.
Then, you should use official client library for Node.js: https://github.com/elastic/elasticsearch-js
To use that module, simply create a client instance
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: '<your_instance_ip>:9200',
log: 'trace'
});
And then push some data to it via client.send
and search for it using client.search
functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With