企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 使用ElasticSearch <br> 控制器内置了 ``ElasticSearch`` 可以通过如下例子来调用 ``` // EDb通过传入一个名称来切换数据源,默认不传是db // search有两个参数,第一是索引名称,第二个是查询语句 this.EDb().search('shop',{ "query": { "match": { "name": "李四" } } }) ``` 返回 ``` { "took" : 559, "timed_out" : false, "_shards" : { "total" : 1, "successful" : 1, "skipped" : 0, "failed" : 0 }, "hits" : { "total" : { "value" : 2, "relation" : "eq" }, "max_score" : 1.89712, "hits" : [ { "_index" : "user", "_type" : "docs", "_id" : "2", "_score" : 1.89712, "_source" : { "name" : "李四", "sex" : 1, "age" : 25, "address" : "河北省" } }, { "_index" : "user", "_type" : "docs", "_id" : "4", "_score" : 0.6931471, "_source" : { "name" : "李华", "sex" : 1, "age" : 26, "address" : "河北省" } } ] } } ``` 关于ElasticSearch的语法总结,可以查看我下面这个手册 > [ElasticSearch开发手册](http://es.zhangyubk.com/2423818) Elasticsearch Node.js文档 > https://www.npmjs.com/package/@elastic/elasticsearch <br>