All Projects → cch123 → Elasticsql

cch123 / Elasticsql

Licence: mit
convert sql to elasticsearch DSL in golang(go)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects
dsl
153 projects

Projects that are alternatives of or similar to Elasticsql

Elasticsearch Ruby
Ruby integrations for Elasticsearch
Stars: ✭ 1,848 (+169%)
Mutual labels:  elastic, search, elasticsearch
Elastix
A simple Elasticsearch REST client written in Elixir.
Stars: ✭ 231 (-66.38%)
Mutual labels:  elastic, search, elasticsearch
Elastichd
Elasticsearch 可视化DashBoard, 支持Es监控、实时搜索,Index template快捷替换修改,索引列表信息查看, SQL converts to DSL等
Stars: ✭ 2,993 (+335.66%)
Mutual labels:  elastic, sql, elasticsearch
Zombodb
Making Postgres and Elasticsearch work together like it's 2021
Stars: ✭ 3,781 (+450.36%)
Mutual labels:  sql, elasticsearch
Elasticsuite
Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
Stars: ✭ 647 (-5.82%)
Mutual labels:  search, elasticsearch
Elasticsearch Dsl Py
High level Python client for Elasticsearch
Stars: ✭ 3,388 (+393.16%)
Mutual labels:  search, elasticsearch
Elasticsearch Rails
Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Stars: ✭ 2,896 (+321.54%)
Mutual labels:  elastic, elasticsearch
Awesome Elasticsearch
A curated list of the most important and useful resources about elasticsearch: articles, videos, blogs, tips and tricks, use cases. All about Elasticsearch!
Stars: ✭ 4,168 (+506.7%)
Mutual labels:  search, elasticsearch
Xapiand
Xapiand: A RESTful Search Engine
Stars: ✭ 347 (-49.49%)
Mutual labels:  search, elasticsearch
Pfelk
pfSense/OPNsense + ELK
Stars: ✭ 417 (-39.3%)
Mutual labels:  elastic, elasticsearch
Reactivesearch
Search UI components for React and Vue: powered by appbase.io / Elasticsearch
Stars: ✭ 4,531 (+559.53%)
Mutual labels:  search, elasticsearch
Elasticsearch Py
Official Elasticsearch client library for Python
Stars: ✭ 3,486 (+407.42%)
Mutual labels:  search, elasticsearch
Toshi
A full-text search engine in rust
Stars: ✭ 3,373 (+390.98%)
Mutual labels:  search, elasticsearch
Calaca
Search UI for Elasticsearch
Stars: ✭ 318 (-53.71%)
Mutual labels:  search, elasticsearch
Android Nosql
Lightweight, simple structured NoSQL database for Android
Stars: ✭ 284 (-58.66%)
Mutual labels:  elastic, sql
Minsql
High-performance log search engine.
Stars: ✭ 356 (-48.18%)
Mutual labels:  search, sql
Searchkit
GraphQL API & React UI components for Elasticsearch. The easiest way to build a great search experience
Stars: ✭ 4,338 (+531.44%)
Mutual labels:  search, elasticsearch
Graphql Compose Elasticsearch
Hide Elastic Search REST API behind GraphQL.
Stars: ✭ 498 (-27.51%)
Mutual labels:  elastic, elasticsearch
Fess
Fess is very powerful and easily deployable Enterprise Search Server.
Stars: ✭ 561 (-18.34%)
Mutual labels:  search, elasticsearch
Helk
The Hunting ELK
Stars: ✭ 3,097 (+350.8%)
Mutual labels:  elastic, elasticsearch
 _____ _         _     ____ _____ ___  ____  ____   ___   _
| ____| |       / \   / ___|_   _|_ _|/ ___|/ ___| / _ \ | |
|  _| | |      / _ \  \___ \ | |  | || |    \___ \| | | || |
| |___| |___  / ___ \  ___) || |  | || |___  ___) | |_| || |___
|_____|_____|/_/   \_\|____/ |_| |___|\____||____/ \__\_\|_____|

Overview

Build Status Go Documentation Coverage Status Go Report Card

This tool converts sql to elasticsearch dsl

Currently support:

  • [x] sql and expression
  • [x] sql or expression
  • [x] equal(=) support
  • [x] not equal(!=) support
  • [x] gt(>) support
  • [x] gte(>=) support
  • [x] lt(<) support
  • [x] lte(<=) support
  • [x] sql in (eg. id in (1,2,3) ) expression
  • [x] sql not in (eg. id not in (1,2,3) ) expression
  • [x] paren bool support (eg. where (a=1 or b=1) and (c=1 or d=1))
  • [x] sql like expression (currently use match phrase, perhaps will change to wildcard in the future)
  • [x] sql order by support
  • [x] sql limit support
  • [x] sql not like expression
  • [x] field missing check
  • [x] support aggregation like count(*), count(field), min(field), max(field), avg(field)
  • [x] support aggregation like stats(field), extended_stats(field), percentiles(field) which are not standard sql function
  • [ ] null check expression(is null/is not null)
  • [ ] join expression
  • [ ] having support

Usage

go get -u github.com/cch123/elasticsql

Demo :

package main

import (
    "fmt"

    "github.com/cch123/elasticsql"
)

var sql = `
select * from aaa
where a=1 and x = '三个男人'
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
`

func main() {
    dsl, esType, _ := elasticsql.Convert(sql)
    fmt.Println(dsl)
    fmt.Println(esType)
}

will produce :

{
    "query": {
        "bool": {
            "must": [
                {
                    "match": {
                        "a": {
                            "query": "1",
                            "type": "phrase"
                        }
                    }
                },
                {
                    "match": {
                        "x": {
                            "query": "三个男人",
                            "type": "phrase"
                        }
                    }
                },
                {
                    "range": {
                        "create_time": {
                            "from": "2015-01-01T00:00:00+0800",
                            "to": "2016-01-01T00:00:00+0800"
                        }
                    }
                },
                {
                    "range": {
                        "process_id": {
                            "gt": "1"
                        }
                    }
                }
            ]
        }
    },
    "from": 100,
    "size": 10,
    "sort": [
        {
            "id": "desc"
        }
    ]
}

aaa

If your sql contains some keywords, eg. order, timestamp, don't forget to escape these fields as follows:

select * from `order` where `timestamp` = 1 and `desc`.id > 0

Warning

To use this tool, you need to understand the term query and match phrase query of elasticsearch.

Setting a field to analyzed or not analyzed will get different results.

Details

For more details of convertion, please refer to the wiki

Other info

When writing this tool, I tried to avoid the deprecated dsl filters and aggregations, so it is compatible with most versions of the elasticsearch

If you have any advices or ideas, welcome to submit an issue or Pull Request!

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].