cch123 / elasticsql Goto Github PK
View Code? Open in Web Editor NEWconvert sql to elasticsearch DSL in golang(go)
License: MIT License
convert sql to elasticsearch DSL in golang(go)
License: MIT License
current:
select * from a where id = missing
the expected:
select * from a where missing(id) = true
original SQL :
select title, price from products where title = '%A%'
expect like that :
{
"_source": [
"title",
"price",
],
"query": {
"bool": {
"must": [
{
"match_phrase": {
"title": {
"query": "%A%"
}
}
}
]
}
},
"from": 0,
"size": 1
}
actually, elasticsql.Convert(sql) didn't generate "_source":["title", "price"]
输入sql转化成dsl语句?
eg.
select count(*) from worksheet;
select sum(account) from worksheet;
Does this library have the capability to perform a conversion from DSL to SQL?
implement the group by
range
date_range
date_histogram(already supported)
...
First of all thanks for the great work!
The functionality check-list mentions that like
operator is implemented for phrase search.
However, in the example, although the strict equality =
is used, the generated elasticsearch query is a phrase match. In that case, as far as I understood, shouldn't it generate a term search instead?
If the example is correct, what is the way to generate a term search query?
select count(DISTINCT deviceId) from uv where deviceId in (select deviceId from uv where userId = 'unknown') and uv.userId != 'unknown';
if Pretty {
var prettyJSON bytes.Buffer
err = json.Indent(&prettyJSON, []byte(dsl), "", " ")
if err != nil {
dsl = ""
} else {
dsl = string(prettyJSON.Bytes())
}
}
eg:
select * from `order`.paymen_info
select `order`, `timestamp` from ccc
没有版本列表,是否从 elasticsearch 2.x 支持到 6.x?
https://elasticsearch.cn/question/5524
你好,如果想要使用multi_match,sql应该使用什么符号进行查询?
elaticsearch sql have below dsl,
{
"aggs" : {
"articles_over_time" : {
"date_histogram" : {
"field" : "date",
"interval" : "1.5h"
}
}
}
}
is it possible?
select * from aaa where remote_addr="111.206.36.1" limit 10;
转换为:
{"query" : {"bool" : {"must" : [{"match" : {"remote_addr" : {"query" : "111.206.36.1", "type" : "phrase"}}}]}},"from" : 0,"size" : 10}
用该dsl语句查询的时候:
{ "error": { "root_cause": [ { "type": "parsing_exception", "reason": "[match] query does not support [type]", "line": 1, "col": 84 } ], "type": "parsing_exception", "reason": "[match] query does not support [type]", "line": 1, "col": 84 }, "status": 400 }
必须要删除 "type" : "phrase" 才行
bigint 自动转成字符串了, 拿进去查询,查出来的结果是错的
Hello, very nice work.
I was wondering if, is there a way to convert QDSL json object into the SQL?
Hello i need to know when we make it large query have alot of join inside SQL possible to make by your Go solution to Elastic Query match ?
Thanks,
George
请问一下 opendistro的_sql/_translate 您了解吗?我实验sql转换为dsl失败了
sql like : select count(id) from A where A.id > 5 group by A.a, A.b;
because of
innerMap["terms"] = msi{ "field": colName.Name.String(), "size": 0, }
will gen the dsl like: "terms":{"field":"field2","size":0}
and then make a error: "reason":"[size] must be greater than 0
using es7.X
原始sql
SELECT
`familyCode`
FROM
`myTable`
WHERE
(`admin` LIKE '%v!_xxx%' ESCAPE '!')
ORDER BY
`updateTime` DESC
LIMIT
10
其中要对admin字段双侧LIKE字符串v_xxx
。
输出的结果:
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"admin": {
"query": "v!_xxx"
}
}
}
]
}
},
"from": 0,
"size": 10,
"sort": [
{
"updateTime": "desc"
}
]
}
其中query.bool.must[0].match_phrase.admin.query字段的值中,!
没有去掉。
使用例程转换下列语句为DSL的时候,来源
select * from table_name group by date_histogram(field='create_time', interval='1h')
报错
syntax error at position 81
interval要改成value么?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.