doushang9172 2019-07-12 13:26
浏览 462

将Elasticsearch DSL Query转换为Sql

I'm converting a project developed with Codeigniter into pure php. However, the project developed with codeigniter used Elasticsearch and I haven't Elastichsearch experience. I need to convert the Elasticsearch dsl query that I have shared below into a sql query to use in pure php. I tried to write the sql query. But I couldn't understand what tables he was going to. Can you help with this?

`` `Here function in controller in codeigniter (old project)

   $elastic_blok_listesi = $this->elastic_model->plaka_takip_blok_ara($cari_id,$sayfa,$size);
    $elastic_blok_listesi = $elastic_blok_listesi['hits']['hits'];

` ``

`` `Here function in Elasticsearch Model in codeigniter (old project)

public function plaka_takip_blok_ara($cari_id=NULL, $page=0, $size=10, $all=NULL)
{

    if($all == TRUE){

        $json = 
            '{
                "size" : 4000,
        "sort" : [
            {"blok_no" : {"order" : "desc"}}
         ],
                "query": {
            "term": {
            "firma_id":"'.$cari_id.'"
            }
            }
            }'
        ;

    }else{

        $from = ($page-1)*$size;

        $json = 
            '{
                "from" : '.$from.', "size" : '.$size.',
        "sort" : [
            {"blok_no" : {"order" : "desc"}}
         ],
                "query": {
            "term": {
            "firma_id":"'.$cari_id.'"
            }
            }
            }'
        ;
    }

    $this->qParam['body'] = $json;
    return  $this->client->search($this->qParam);
}

` ``

`` `Here My sql in pure php (new project)

  $db->query("
    SELECT * 
    FROM ?
    WHERE firma_id='$cari_id'
    ORDER BY blok_no DESC
");

` ``

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度