《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署——3.4.1.7.阿里云Elasticsearch服务(3) https://developer.aliyun.com/article/1231305
步骤四:创建文档并插入数据
使用 _bulk API,批量插入数据。
POST /product_info/_doc/_bulk {"index":{}} {"productName":"大健康天天理财","annual_rate":"3.2200%","describe":"180天定期理财,最低20000起投,收益稳定,可以自助选择消息推送"} {"index":{}} {"productName":"西部通宝","annual_rate":"3.1100%","describe":"90天定投产品,最低10000起投,每天收益到账消息推送"} {"index":{}} {"productName":"安详畜牧产业","annual_rate":"3.3500%","describe":"270天定投产品,最低40000起投,每天收益立即到账消息推送"} {"index":{}} {"productName":"5G设备采购月月盈","annual_rate":"3.1200%","describe":"90天定投产品,最低12000起投,每天收益到账消息推送"} {"index":{}} {"productName":"新能源动力理财","annual rate":"3.0100%","describe":"30天定投产品推荐,最低8000起投,每天收益会消息推送"} {"index":{}} {"productName":"微贷赚","annual_rate":"2.7500%","describe":"热门短期产品,3天短期,无须任何手续费用,最低500起投,通过短信提示获取收益消息"}
如果返回显示"errors" : false,说明数据插入成功。
步骤五:搜索数据
全文搜索搜索描述内容包含每天收益到账消息推送的所有产品。
GET /product_info/_doc/_search { "query": { "match": { "describe": "每天收益到账消息推送" } } }
搜索成功后,返回结果如下。
{ "took" : 21, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : 6, "max_score" : 1.3968885, "hits" : [ { "_index" : "product_info", "_type" : "products", "_id" : "WLvWYXAB8Rql5AUxLqUU", "_score" : 1.3968885, "_source" : { "productName" : "西部通宝", "annual_rate" : "3.1100%", "describe" : "90天定投产品,最低10000起投,每天收益到账消息推送" } }, { "_index" : "product_info", "_type" : "products", "_id" : "WrvWYXAB8Rql5AUxLqUU", "_score" : 1.3968885, "_source" : { "productName" : "5G设备采购月月盈", "annual_rate" : "3.1200%", "describe" : "90天定投产品,最低12000起投,每天收益到账消息推送" } }, { "_index" : "product_info", "_type" : "products", "_id" : "WbvWYXAB8Rql5AUxLqUU", "_score" : 1.3547361, "_source" : { "productName" : "安详畜牧产业", "annual_rate" : "3.3500%", "describe" : "270天定投产品,最低40000起投,每天收益立即到账消息推送" } }, { "_index" : "product_info", "_type" : "products", "_id" : "W7vWYXAB8Rql5AUxLqUU", "_score" : 1.1507283, "_source" : { "productName" : "新能源动力理财", "annual rate" : "3.0100%", "describe" : "30天定投产品推荐,最低8000起投,每天收益会消息推送" } }, { "_index" : "product_info", "_type" : "products", "_id" : "XLvWYXAB8Rql5AUxLqUU", "_score" : 0.5753642, "_source" : { "productName" : "微贷赚", "annual_rate" : "2.7500%", "describe" : "热门短期产品,3天短期,无须任何手续费用,最低500起投,通过短信提示获取收益消息" } }, { "_index" : "product_info", "_type" : "products", "_id" : "V7vWYXAB8Rql5AUxLqUU", "_score" : 0.31854028, "_source" : { "productName" : "大健康天天理财", "annual_rate" : "3.2200%", "describe" : "180天定期理财,最低20000起投,收益稳定,可以自助选择消息推送" } } ] } }
《Elastic Stack 实战手册》——三、产品能力——3.4.入门篇——3.4.1.Elastic Stack 安装部署——3.4.1.7.阿里云Elasticsearch服务(5) https://developer.aliyun.com/article/1231302