首先应用“限制”,然后筛选所选数据

ih99xse1  于 2021-08-09  发布在  Java
关注(0)|答案(0)|浏览(101)

请帮助将sql查询转换为elasticsearch查询。我的问题是,我不知道如何对应用了限制的数据应用筛选器(例如,在我的示例中,这些是“name”和“city”字段)。也就是说,我需要首先应用限制,然后对所选数据应用过滤器(“name”和“city”字段)。
下面是sql查询的一个示例:

"select * from (select * from table_name where code='1214' and state='FL' and county='Lee' LIMIT 100) as t1 WHERE name LIKE '%Jenny%' AND city LIKE '%Alva%'"

我必须对这个elastiscearch查询进行更改才能得到所需的结果。

$parameters =  [
                        "index" => "my_index",
                        "type" => "my_data",
                        "from" => 0,
                        "size" => 100,
                        "body" => [
                            "query" => [
                                "bool" => [
                                    "must" => [
                                        [
                                            "match" => [
                                                "code" => "1214"
                                            ]
                                        ],
                                        [
                                            "match" => [
                                                "state" => "FL"
                                            ]
                                        ],
                                        [
                                            "match" => [
                                                "county" => "Lee"
                                            ]
                                        ]
                                    ]
                                ],
                            ]
                        ]
                    ];

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题