首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过PowerShell的Freebase MQL查询

通过PowerShell的Freebase MQL查询
EN

Stack Overflow用户
提问于 2014-12-08 06:58:15
回答 1查看 106关注 0票数 0

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

代码语言:javascript
复制
$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 = @(); 
            }))))

显示结果:

代码语言:javascript
复制
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具有以下示例查询:

代码语言:javascript
复制
{
  "q1" : {
    "as_of_time" : "2007-01-09T22:00:56.0000Z",
    "query" : [
      {
        "domain" : "/architecture",
        "id" : null,
        "return" : "count",
        "timestamp" : null,
        "type" : "/type/type"
      }
    ]
  }
}

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

EN

回答 1

Stack Overflow用户

发布于 2014-12-14 08:05:21

代码语言:javascript
复制
$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'
    )
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27348886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档