【问题标题】:Freebase MQL query via PowerShell通过 PowerShell 进行 Freebase MQL 查询
【发布时间】:2014-12-07 22:58:15
【问题描述】:

这是 PowerShell 中 MQL overview 的第一个示例:

$result = Invoke-RestMethod `
    -Uri ('https://www.googleapis.com/freebase/v1/mqlread?query={0}' -f `
        [System.Web.HttpUtility]::UrlEncode(
            (ConvertTo-Json @(@{ 
                type = '/astronomy/planet'; id = @(); name = @(); 
            }))))

显示结果:

PS C:\> $result.result

type                                 id                                   name                                
----                                 --                                   ----                                
/astronomy/planet                    {/en/earth}                          {Earth}                             
/astronomy/planet                    {/en/venus}                          {Venus}                             
/astronomy/planet                    {/en/mars}                           {Mars}                              
/astronomy/planet                    {/wikipedia/pt_id/1214}              {Mercury}                           
/astronomy/planet                    {/en/jupiter}                        {Jupiter}                           
/astronomy/planet                    {/en/neptune}                        {Neptune}                           
/astronomy/planet                    {/en/saturn}                         {Saturn}                            
/astronomy/planet                    {/en/uranus}                         {Uranus}                            

MQL cookbook 具有以下示例查询:

{
  "q1" : {
    "as_of_time" : "2007-01-09T22:00:56.0000Z",
    "query" : [
      {
        "domain" : "/architecture",
        "id" : null,
        "return" : "count",
        "timestamp" : null,
        "type" : "/type/type"
      }
    ]
  }
}

通过 PowerShell 提交该查询的好方法是什么?

【问题讨论】:

    标签: powershell freebase mql


    【解决方案1】:
    $result = Invoke-RestMethod `
        -Uri (
            'https://www.GoogleAPIs.com/freebase/v1/mqlread?' + 
            ('query={0}' -f [System.Web.HttpUtility]::UrlEncode(
                (ConvertTo-Json -Depth 100 `
                    @(
                        @{
                            domain = '/architecture';
                            id = $null;
                            return = 'count';
                            timestamp = $null;
                            type = '/type/type'
                        }
                    )
                )
            )) +
            '&as_of_time=2007-01-09'
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多