zombodb sql functions 说明

zombodb 提供了好多方便的sql 函数工具类以及帮助函数

查看zombodb 版本zdb.version()

select * from zdb.version();
 version
----------
 10-1.0.3
(1 row)

es http 请求的 zdb.request

  • 函数签名
FUNCTION zdb.request(
    index regclass, 
    endpoint text, 
    method text DEFAULT 'GET', 
    post_data text DEFAULT NULL) 
RETURNS text
  • 使用

    比如我们查看es索引信息

SELECT zdb.request('idxproducts', '/');
                        request
--------------------------------------------------------
 { +
     "name": "YYRl4wX", +
     "tagline": "You Know, for Search", +
     "version": { +
         "number": "6.6.0", +
         "build_date": "2019-01-24T11:27:09.439740Z", +
         "build_hash": "a9861f4", +
         "build_type": "tar", +
         "build_flavor": "default", +
         "build_snapshot": false, +
         "lucene_version": "7.6.0", +
         "minimum_wire_compatibility_version": "5.6.0",+
         "minimum_index_compatibility_version": "5.0.0"+
     }, +
     "cluster_name": "docker-cluster", +
     "cluster_uuid": "T1OsqT0rRimOJSucUVKDcg" +
 }
(1 row)

查看索引名称信息zdb.index_name

SELECT zdb.index_name('idxproducts');
           index_name
---------------------------------
 12358.2200.17166.17176-91249167
(1 row)

查询索引对应的后端es 地址zdb.index_url

select * from zdb.index_url('idxproducts');
         index_url
----------------------------
 http://elasticsearch:9200/
(1 row)

查看索引映射zdb.index_mapping

select * from zdb.index_url("idxproducts");

--------------------------------------------------------------------------------------------------------------------------
 { +
         "mappings": { +
             "doc": { +
                 "_all": { +
                     "enabled": false +
                 }, +
                 "properties": { +
                     "id": { +
                         "type": "long" +
                     }, +
                     "name": { :

--------------------------------------------------------------------------------------------------------------------------
 { +
         "mappings": { +
             "doc": { +
                 "_all": { +
                     "enabled": false +
                 }, +
                 "properties": { +
                     "id": { +
                         "type": "long" +
                     }, +
                     "name": { +
:

--------------------------------------------------------------------------------------------------------------------------
 { +
         "mappings": { +
             "doc": { +
                 "_all": { +
                     "enabled": false +
                 }, +
                 "properties": { +
                     "id": { +
                         "type": "long" +
                     }, +
                     "name": { +
                         "type": "text", +
                         "copy_to": [ +
                             "zdb_all" +
                         ], +
                         "analyzer": "zdb_standard", +
                         "fielddata": true +
                     }, +
                     "price": { +
                         "type": "long" +
                     }, +
                     "zdb_all": { +
                         "type": "text", +
                         "analyzer": "zdb_all_analyzer" +
                     }, +
                     "keywords": { +
                         "type": "keyword", +
                         "copy_to": [ +
                             "zdb_all" +
                         ], +
                         "normalizer": "lowercase", +
                         "ignore_above": 10922 +
                     }, +
                     "zdb_cmax": { +
                         "type": "integer" +
                     }, +
                     "zdb_cmin": { +
                         "type": "integer" +
                     }, +
                     "zdb_ctid": { +
                         "type": "long" +
                     }, +
                     "zdb_xmax": { +
                         "type": "long" +
                     },
....

参考资料

https://github.com/zombodb/zombodb/blob/master/SQL-FUNCTIONS.md

posted on 2019-04-02 18:17  荣锋亮  阅读(196)  评论(0编辑  收藏  举报

导航