Ach*_*eka 6 node.js express elasticsearch
我想建一个应用程序,这将主要是获取资源的API,现在我已经听说了很多关于Nodejs和ElasticSearch我知道一点和的NodeJS快递框架。但我不知道如何将 ElasticSearch 与 Express 框架集成。
小智 6
npm install elasticsearch --save要使用该模块,只需创建一个客户端实例
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);
});
Run Code Online (Sandbox Code Playgroud)有用的链接https://blog.raananweber.com/2015/11/24/simple-autocomplete-with-elasticsearch-and-node-js/
| 归档时间: |
|
| 查看次数: |
5029 次 |
| 最近记录: |