nodejs elasticsearch基础使用
来源:互联网 发布:电脑pe手动备份数据 编辑:程序博客网 时间:2024/06/05 21:14
/*链接到elasticsearch数据库*/var elasticsearch = require('elasticsearch');var client = new elasticsearch.Client({ host: 'localhost:9200', log: 'trace'});
- 插入数据
client.index({ index: 'myindex', //相当于database type: 'mytype2', //相当于table id: JSON.stringify(new Date().getTime()),// 数据到唯一标示,id存在则为更新,不存在为插入 body: { title: 'Test 1', tags: ['y', 'z'], published: true, published_at: '2013-01-01', counter: 1, name: '999' }//文档到内容}, (error, response)=>{ // console.log(error) console.log(response)});
删除数据:
client.delete({ index: 'myindex', type: 'mytype', id: '3' }, (error, response)=>{ // ...删除id为3的数据 });
查询数据:
client.search({ index: 'myindex', type:'mytype', body:{ query:{ // match:{ // name:'yyk' // } "terms" :{ "_id" : ["6"] } } }}, function (error, response) { // ... response.hits.hits.map((v)=>console.log(v))});
阅读全文
0 0
- nodejs elasticsearch基础使用
- elasticsearch--搜索_Java基础使用
- nodejs koa2的基础使用
- Nodejs:mongo-connector同步mongo数据;使用elasticsearch搜索
- NodeJS基础:exports模块的使用
- NodeJS基础:querystring 模块的使用
- NodeJS基础:readline模块的使用
- Elasticsearch基础
- elasticsearch 基础
- Elasticsearch基础
- Elasticsearch基础
- elasticsearch基础
- elasticsearch基础
- ElasticSearch基础
- ElasticSearch基础
- Nodejs 基础
- NodeJS基础
- nodeJs基础
- 谷歌账号手机验证失败的一些解决方法
- 为什么写博客
- 在FPGA的ROMIP核中导入由txt建立的coe数据文件并仿真
- 【 Tomcat 】tomcat8.0 基本参数调优配置
- 编译ARToolKit遇到的几个问题
- nodejs elasticsearch基础使用
- 用Java实现约瑟夫问题
- [欧拉回路] 51NOD1967. 路径定向
- ios高级动画的简单实现
- 梯度爆炸分析
- 数据结构实验之查找七:线性之哈希表
- lamp
- 在线英英词典
- Nepire的校OJ入门题解—17蓝桥选拔篇(七)