apility / elasticsearch-sql-parser
Library for parsing SQL into the Elasticsearch DSL
v1.0.7
2022-07-26 12:56 UTC
Requires
- php: >=7.4
- greenlion/php-sql-parser: ^4.5
Requires (Dev)
- phpstan/phpstan: ^1.8
README
Installation
composer require apility/elasticsearch-sql-parser
Usage
<?php use Apility\ElasticSearch\SQLParser; $query = "SELECT * FROM articles WHERE published = 1 ORDER BY updated LIMIT 10"; $parsed = SQLParser::parse($query); // ElasticSearch Query DSL
Example output
{ "index": "articles", "from": 0, "size": 10, "query": { "bool": { "filter": [ { "bool": { "must": [ { "match_phrase": { "published": { "query": "1" } } } ] } } ] } }, "sort": [ { "updated": { "order": "ASC" } } ], "_source": { "include": [ "id", "name", "author" ] } }