EsParserphp的运行类库,通过写sql转换dsl查询elasticsearchcomposerusing{"require":{"qieangel2013/esparser":"dev-master"}}composerinstallrequire__DIR__.'/vendor/autoload.php';//$sql='select*fromalp_dish_sales_saaswheresidin(994,290)limit1,10';//$sql='updatealp_dish_sales_saassetmid=3whereadsid=15125110';//$sql='deletefromalp_dish_sales_saaswhereadsid=15546509';//$sql="select*,concat_ws('_',category_name.keyword,dish_name.keyword,sku_name.keyword)asdfgfromalp_dish_sales_saaswheresale_date>'2017-01-01'andsale_date<'2017-09-02'groupbydfgorderbytotal_countdesc";$sql='select*,DATE_FORMAT(sale_date,"%Y-%m-%d")asdaysfromalp_dish_sales_saasgroupbydays';$es_config=array('索引'=>"alp_dish_sales_saas",'type'=>"alp_dish_sales_saas",'url'=>"http://127.0.0.1:9200",'version'=>"5.x"//1.x2.x5.x6.x,不能配置,系统会请求获取版本,这样会多一个request,建议配置);$parser=newEsParser($sql,true,$es_config);//第三个参数是es的配置参数,一定要配置print_r($parser->result);//打印结果//print_r($parser->explain());//打印dslcommon调用require_oncedirname(__FILE__)。'/src/library/EsParser.php';//$sql='select*fromalp_dish_sales_saaswheresidin(994,290)limit1,10';//$sql='updatealp_dish_sales_saassetmid=3whereadsid=15125110';//$sql='deletefromalp_dish_sales_saaswhereadsid=15546509';//$sql="select*,concat_ws('_',category_name.keyword,dish_name.keyword,sku_name.keyword)asdfgfromalp_dish_sales_saaswheresale_date>'2017-01-01'和sale_date<'2017-09-02'groupbydfgorderbytotal_countdesc";$sql='select*,DATE_FORMAT(sale_date,"%Y-%m-%d")asdays从alp_dish_sales_saas按天分组';$es_config=array('index'=>"alp_dish_sales_saas",'type'=>"alp_dish_sales_saas",'url'=>"http://127.0.0.1:9200",'version'=>"5.x"//1.x2.x5.x6.x,可以不配置,系统会请求获取版本,这样会多一个请求,建议配置);$解析器=newEsParser($sql,true,$es_config);//第三个参数是es的配置参数,一定要配置print_r($parser->result);//打印结果//print_r($parser->explain());//打印dsl目前支持的SQL函数*SQLSelect*SQLDelete*SQLUpdate*SQLWhere*SQLOrderBy*SQLGroupBy*SQLAND&OR*SQLLike*SQLCOUNTdistinct*SQLIn*SQLNotIn*SQLavg()*SQLcount()*SQLmax()*SQLmin()*SQLsum()*SQLBetween*SQLAliases*SQLconcat_ws*使用SQLDATE_FORMATE注意事项请在配置项填写es版本,这样系统不会请求获取Version,这样就不会再请求了,建议配置通讯使用qq群:578276199项目地址github:https://github.com/qieangel2013/EsParseroschina:https://gitee.com/qieangel2013/EsParser
