ElasticSQL
-----------
[![Build Status](https://travis-ci.org/farmerx/elasticsql.svg?branch=master)](https://travis-ci.org/farmerx/elasticsql)
[![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://godoc.org/github.com/farmerx/elasticsql)
[![Coverage Status](https://coveralls.io/repos/github/farmerx/elasticsql/badge.svg?branch=master)](https://coveralls.io/github/farmerx/elasticsql?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/farmerx/elasticsql)](https://goreportcard.com/report/github.com/farmerx/elasticsql)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/farmerx/elasticsql/blob/master/LICENSE)
> ElasticSQL package converts SQL to ElasticSearch DSL
## SQL Features Support:
- [x] SQL Select
- [x] SQL Where
- [x] SQL Order BySQL
- [x] SQL Group By
- [x] SQL AND & OR
- [x] SQL Like & NOT Like
- [x] SQL COUNT distinct
- [x] SQL In & Not In
- [x] SQL Between
- [x] SQL avg()、count(*), count(field), min(field), max(field)
## Beyond SQL Features Support:
- [x] ES TopHits
- [x] ES date_histogram
- [x] ES STATS
- [x] ES RANGE
- [x] ES DATE_RANGE
*Improvement : now the query DSL is much more flat*
## SQL Usage
Query
```
select * from test where a=1 and b="c" and create_time between '2015-01-01T00:00:00+0800' and '2016-01-01T00:00:00+0800' and process_id > 1 order by id desc limit 100,10
```
Aggregation
```
select avg(age),min(age),max(age),count(student),count(distinct student) from test group by grade,class limit 10
```
Beyond SQL
* range age group 20-25,25-30,30-35,35-40
```
SELECT COUNT(age) FROM bank GROUP BY range(age, 20,25,30,35,40)
```
* range date group by your config
```
SELECT online FROM online GROUP BY date_range(field="insert_time",format="yyyy-MM-dd" ,"2014-08-18","2014-08-17","now-8d","now-7d","now-6d","now")
```
* range date group by day
```
select * from test group by date_histogram(field="changeTime",interval="1h",format="yyyy-MM-dd HH:mm:ss")
```
* stats
```
SELECT online FROM online group by stats(field="grade")
```
* topHits
```
select top_hits(field="class", hitssort="age:desc", taglimit = "10", hitslimit = "1", _source="name,age,class,gender") from school
```
## PKG Usage
-------------
> go get github.com/farmerx/elasticsql
Demo :
```go
package main
import (
"fmt"
"github.com/farmerx/elasticsql"
)
var sql = `
select * from test where a=1 and b="c" and create_time between '2015-01-01T00:00:00+0800' and '2016-01-01T00:00:00+0800' and process_id > 1 order by id desc limit 100,10
`
var sql2= `
select avg(age),min(age),max(age),count(student) from test group by class limit 10
`
var sql3= `
select * from test group by class,student limit 10
`
var sql4 = `
select * from test group by date_histogram(field="changeTime",interval="1h",format="yyyy-MM-dd HH:mm:ss")
`
func main() {
esql := elasticsql.NewElasticSQL(eslasticsql.InitOptions{})
table, dsl, err := esql.SQLConvert(sql)
fmt.Println(table, dsl, err)
}
```
## Licenses
This program is under the terms of the MIT License. See [LICENSE](https://github.com/farmerx/elasticsql/blob/master/LICENSE) for the full license text.
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ElasticHD-master.zip (210个子文件)
.babelrc 234B
app.ff12067c7a90148fbef795a571260723.css 291KB
Dockerfile 372B
.editorconfig 147B
fontawesome-webfont.674f50d.eot 162KB
glyphicons-halflings-regular.f4769f9.eot 20KB
.eslintignore 23B
.eslintrc 95B
.gitignore 9B
.gitkeep 0B
statik.go 16.09MB
sql.go 55KB
ast.go 22KB
utils.go 15KB
search.go 14KB
searchfilter.go 12KB
clusterstatresponses.go 12KB
corebulk.go 12KB
token.go 11KB
corebulk_test.go 11KB
marshal.go 10KB
searchfilter_test.go 9KB
struct.go 9KB
sqltypes.go 8KB
unmarshal_util.go 8KB
indicesputmapping_test.go 8KB
catnodeinfo.go 8KB
unmarshal.go 8KB
coresearch.go 8KB
searchsearch_test.go 7KB
searchquery.go 7KB
clusternodesinfo.go 6KB
elasticsql.go 6KB
searchsearch.go 5KB
connection.go 5KB
indicesputmapping.go 5KB
searchaggregate.go 5KB
coretest_test.go 4KB
catindexinfo_test.go 4KB
coreupdate.go 4KB
coreindex.go 4KB
parsed_query.go 4KB
searchaggregate_test.go 4KB
snapshot.go 4KB
coreget.go 4KB
analyzer.go 4KB
baseresponse.go 4KB
baserequest.go 4KB
clusterhealth.go 3KB
setup_test.go 3KB
searchhighlight.go 3KB
catshardinfo_test.go 3KB
request.go 3KB
searchfacet.go 3KB
chunked_writer.go 3KB
tracked_buffer.go 3KB
request_test.go 3KB
searchhighlight_test.go 2KB
clusterreroute.go 2KB
catresponses.go 2KB
catshardinfo.go 2KB
main.go 2KB
catindexinfo.go 2KB
coresearch_test.go 2KB
coremorelikethis.go 2KB
marshal_util.go 2KB
coremget.go 2KB
indicescreateindex.go 2KB
connection_test.go 2KB
coredeletebyquery.go 2KB
corepercolate.go 2KB
clusternodesinfo_test.go 2KB
clusterupdatesettings.go 2KB
hack.go 2KB
indicesanalyze.go 2KB
indicesaliases.go 2KB
common.go 2KB
corevalidate.go 2KB
indicesflush.go 2KB
corecount.go 2KB
corepercolate_test.go 2KB
coreexample_test.go 2KB
indicesrefresh.go 2KB
indicesopencloseindex.go 1KB
indicessnapshot.go 1KB
elasticsql_test.go 1KB
coreexplain.go 1KB
indicesclearcache.go 1KB
indicesdeletemapping.go 1KB
clusterhealthresponses.go 1KB
indicesoptimize.go 1KB
clusternodesshutdown.go 1KB
catnodeinfo_test.go 1KB
searchsort.go 1KB
indicesdeletemapping_test.go 1KB
indicesstatus.go 1KB
indicesdeleteindex.go 1KB
indicesindicesexists.go 1KB
searchfacet_test.go 1KB
coredelete.go 1KB
共 210 条
- 1
- 2
- 3
资源评论
m0_72731342
- 粉丝: 2
- 资源: 1832
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- index.jsp
- Screenshot_20240521_090410_com.huawei.android.launcher.jpg
- 单文件制作工具 7.0.2.3851-x86-x64
- Linux命令.xmind
- 基于Transformer实现的跨域Cross-view实时Map-view语义分割算法-附项目源码-优质项目实战.zip
- linux常用命令大全-.zip
- 2024彩虹聚合DNS管理系统源码 管理系统快速开发平台 聚合平台管理.zip
- elasticsearch介绍-.zip
- nodejs安装及环境配置-.zip
- 谷歌浏览器自动化测试版113.0.5672.0(包含linux,windows32/64,mac三个版本,不会自动更新)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功