1

我现在正在使用 druid 很短的时间,并且正在测试注册的查找功能。

我已经在 http://:/druid/coordinator/v1/lookups 下创建了查找,如下所示:

{
    "__default": {
        "home_post_code": {
          "type": "map",
          "map": {"13210": "Syracuse, NY"}
        }
    }
}

据我了解,对于下面查询部分中声明的维度“home_post_code”,此映射应将所有出现的值“13210”替换为“纽约州锡拉丘兹”:

    ...
    },
    "dimensions": [
        "home_post_code",
        {
            "type":"registeredLookup",
            "dimension" : "home_post_code",
            "outputName" :  "home_post_code_description",
            "lookup":"home_post_code",
            "retainMissingValue": true,
            "injective": false
        }
    ],
    ...

问题是当我执行查询时,“home_post_code_description”列中的值没有根据映射替换。

我能够在 http://:/druid/listen/v1/lookups 中列出查找,所以我相信它已正确注册。

我在这里想念什么?我应该更改任何配置吗?

提前致谢。

4

3 回答 3

2

您可以尝试一些方法来解决它。

  1. 删除所有不使用的查找
  2. 要么使用“__default”作为层名称,要么提及您想要的任何层,但不要忘记在所有 runtime.properties 中提及 as druid.lookup.lookupTierIsDatasource=false druid.lookup.lookupTier=_default_tier
  3. 确保 GET 正在处理该查找(请参阅 get api for lookup 的文档)

例如:一个典型的查找查询看起来像

{  
   "intervals":[  
      "Your interval"
   ],
   "granularity":"all",
   "queryType":"groupBy",
   "threshold":1000,
   "dataSource":"your datasource name",
   "aggregations":[  
      {  
         "type":"doubleSum",
         "name":"sum",
         "fieldName":"your field"
      }
   ],
   "dimensions":[  
      {  
         "type":"default",
         "dimension":"your dimention mentioned in lookup- Key",
         "outputName":"anyoutput name",
         "outputType":<"STRING"|"LONG"|"FLOAT">,
         "name":"your registered lookup name"
      },
      {  

          "type" : "extraction",
          "dimension" : "your dimention mentioned in lookup- Key",
          "outputName" : "anyout put name",
          "outputType": "<"STRING"|"LONG"|"FLOAT">,
          "extractionFn" : {
               "type":"registeredLookup",
                "lookup":"your registered lookup name",
                "retainMissingValue":true

            }

      }
   ],
   "metric":{  

   }
}`
```

这会奏效..经过一番努力后,我终于将这个问题分解为解决方案

于 2018-07-26T10:07:39.133 回答
1

您的查询可能是错误的。您应该将ExtractionDimensionSpec与作为注册查找提取函数的提取函数一起使用。

  "dimensions" : [ {
      "type" : "extraction",
      "dimension" : "home_post_code",
      "outputName" : "home_post_code_description",
      "extractionFn": {
          "type":"registeredLookup",
          "lookup": "home_post_code",
          "retainMissingValue":true,
          "injective":false
      }
  } ]
于 2017-01-04T17:26:23.007 回答
0

您应该使用extractionFunction,它使用给定的提取函数转换维度值。

"dimensions": [
    {
        "dimension": "id",
        "type": "extraction",
        "extractionFn": {
          "type":"lookup",
          "lookup": {
            "type":"map",
            "map":{
                "13210": "Syracuse, NY"
            }
          },
          "retainMissingValue":false,
          "injective":false
        }
    }
]
于 2017-04-24T20:41:37.670 回答