使用技術(shù):
ElasticSearch搜索引擎+Kibana+Nginx負載均衡+Python爬蟲+Redis實現(xiàn)熱搜+Jquery實現(xiàn)Vue模版+Egg
使用方法:
- 將Mysql的數(shù)據(jù)導(dǎo)入ElasticSearch
- 運行ElasticSearch
- 使用egg(主要是有鏈接ElasticSearch的架包辈末,注意包的版本要和ES的版本對應(yīng))
- 前端使用Nginx,主要是為了跨域蟹漓。
不足:egg的ES部分增刪查改那些因為加班的原因還未實現(xiàn)巾乳。
參考文檔:
https://blog.csdn.net/Tyro_java/article/details/106565440
參照視頻:
https://www.itying.com/goods-941.html
碼云地址:
https://gitee.com/leeyamaster/room
項目效果
核心代碼:
配置文件:
module.exports = appInfo => {
const config = exports = {};
config.keys = appInfo.name + '_1587648814940_7499';
config.middleware = [];
exports.elasticsearch = {
host: 'localhost:9200',
apiVersion: '6.6'
};
return config;
};
核心請求:
async index() {
const {
ctx
} = this;
const req = ctx.request.body;
ctx.body = req;return;
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
})
const result = await client.search({
index: 'index',
type: 'room',
body: {
query: {
match: {
address: '青羊'
}
}
}
})
ctx.body = result;
}