小编rei*_*neh的帖子

将sql转换为dsl elasticsearch查询

我想将此SQL查询转换为弹性DSL查询语言

SELECT t.pk_c_c_s,
       t.fk_c_c_id,
       t.s_b_a,
       t.datetime,
       SUBSTR(t.datetime, 0, 7) m,
       (
         SELECT SUM(i.s_b_a) sarpu
         FROM TBL_C_C_S i
         WHERE substr(i.datetime, 0, 7) = substr(t.datetime, 0, 7)
           AND i.datetime <= t.datetime
           AND i.fk_c_c_id = t.fk_c_c_id
         GROUP BY SUBSTR(i.datetime, 0, 7)
        ) s
FROM TBL_C_C_S t
Run Code Online (Sandbox Code Playgroud)

我怎么能将这个SQL查询转换为elasticsearch

这是我在弹性搜索中的方式

POST /c_c_s_index_test/_search
{ "size":0,
  "aggs": {
    "customer": {
      "terms": {
        "field": "fk_c_c_id",
        "size": 5
      },
      "aggs": {
        "sumscore": {
          "sum": {
            "field": "s_b_a"
          }
        },
        "month": {
          "date_histogram": {
            "field": "datetime",
            "interval": "1M",
            "min_doc_count": 1 …
Run Code Online (Sandbox Code Playgroud)

sql oracle dsl aggregation elasticsearch

6
推荐指数
1
解决办法
594
查看次数

如何通过用户定义类型的字段过滤cassandra查询

如何按用户定义的类型字段过滤cassandra查询?我想在我的cassandra数据库中创建人员表,所以我在我的cassandra数据库中创建这个用户定义的类型.

    create type fullname ( firstname text, lastname text );
Run Code Online (Sandbox Code Playgroud)

我也有这张桌子.

    create table people ( id UUID primary key, name frozen <fullname> );
Run Code Online (Sandbox Code Playgroud)

我需要过滤我的查询以了解姓jolie的所有人.我该如何从这个表中查询.以及如何在cassandra中过滤和查询?我知道我可以删除fullname类型并将firstname和lastname添加到主表,但它是我想要做的样本.我必须具有全名类型.

user-defined-types cassandra frozen-columns frozen

5
推荐指数
1
解决办法
5321
查看次数