| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
zjsrg
9年前发布

用SQL语句查询elasticsearch

来自: http://blog.csdn.net//jiao_fuyou/article/details/50556602


以前我是这样查询elasticsearch的:

POST /cdr*/hj_scpcdr/_search  {    "from" : 0,    "size" : 0,    "_source" : {      "includes" : [ "filedate", "vestss", "permark", "subpp", "SUM" ],      "excludes" : [ ]    },    "fields" : [ "filedate", "vestss", "permark", "subpp" ],    "sort" : [ {      "filedate" : {        "order" : "asc"      }    }, {      "vestss" : {        "order" : "asc"      }    }, {      "permark" : {        "order" : "asc"      }    }, {      "subpp" : {        "order" : "asc"      }    } ],    "aggregations" : {      "filedate" : {        "terms" : {          "field" : "filedate",          "size" : 200,          "order" : {            "_term" : "asc"          }        },        "aggregations" : {          "vestss" : {            "terms" : {              "field" : "vestss",              "size" : 0,              "order" : {                "_term" : "asc"              }            },            "aggregations" : {              "permark" : {                "terms" : {                  "field" : "permark",                  "size" : 0,                  "order" : {                    "_term" : "asc"                  }                },                "aggregations" : {                  "subpp" : {                    "terms" : {                      "field" : "subpp",                      "size" : 0,                      "order" : {                        "_term" : "asc"                      }                    },                    "aggregations" : {                      "SUM(calldura60)" : {                        "sum" : {                          "field" : "calldura60"                        }                      }                    }                  }                }              }            }          }        }      }    }  }

但是我现在可以这样查询ES了:

POST /_sql  select filedate,vestss,permark,subpp,sum(calldura60) from cdr*/hj_scpcdr group by filedate,vestss,permark,subpp order by filedate,vestss,permark,subpp

没错,安装elasticsearch-sql插件就行了
https://github.com/NLPchina/elasticsearch-sql

这里写图片描述

 本文由用户 zjsrg 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1455248220089.html
ElasticSearch 搜索引擎