您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

calchistogram 方法calchistogram Method

calchistogram 方法可计算与结构化查询表达式匹配的对象,并计算其属性值的分布。The calchistogram method computes the objects matching a structured query expression and calculates the distribution of their attribute values.

请求Request

http://<host>/calchistogram?expr=<expr>[&options]

NameName Value 描述Description
exprexpr 文本字符串Text string 指定用于计算直方图的索引实体的结构化查询表达式。Structured query expression that specifies the index entities over which to calculate histograms.
attributesattributes 文本字符串(默认值为 "")Text string (default="") 要包含在响应中的以逗号分隔的属性列表。Comma-delimited list of attribute to included in the response.
计数count 数字(默认值为 10)Number (default=10) 要返回的结果数。Number of results to return.
offsetoffset 数字(默认值为 0)Number (default=0) 要返回的第一个结果的索引。Index of the first result to return.

响应 (JSON)Response (JSON)

JSONPathJSONPath 描述Description
$.expr$.expr expr 参数来自请求。expr parameter from the request.
$.num_entities$.num_entities 匹配实体的总数。Total number of matching entities.
$.histograms$.histograms 直方图数组,每个请求的属性一个。Array of histograms, one for each requested attribute.
$.histograms[*].attribute$.histograms[*].attribute 计算直方图的属性的名称。Name of the attribute over which the histogram was computed.
$.histograms[*].distinct_values$.histograms[*].distinct_values 此属性的匹配实体中的非重复值的数量。Number of distinct values among matching entities for this attribute.
$.histograms[*].total_count$.histograms[*].total_count 此属性的匹配实体中的值实例的总数。Total number of value instances among matching entities for this attribute.
$.histograms[*].histogram$.histograms[*].histogram 此属性的直方图数据。Histogram data for this attribute.
$.histograms[*].histogram[*].value$.histograms[*].histogram[*].value 属性值。Attribute value.
$.histograms[*].histogram[*].logprob$.histograms[*].histogram[*].logprob 具有此属性值的匹配实体的自然对数总概率。Total natural log probability of matching entities with this attribute value.
$.histograms[*].histogram[*].count$.histograms[*].histogram[*].count 具有此属性值的匹配实体的数量。Number of matching entities with this attribute value.
$.aborted$.aborted 如果请求超时,则为 True。True if the request timed out.

示例Example

在学术出版物示例中,以下代码计算自 2013 年以来针对特定作者按年份和按关键字的出版物计数直方图:In the academic publications example, the following calculates a histogram of publication counts by year and by keyword for a particular author since 2013:

http://<host>/calchistogram?expr=And(Composite(Author.Name=='jaime teevan'),Year>=2013)&attributes=Year,Keyword&count=4

响应表明有 37 篇论文与查询表达式匹配。The response indicates that there are 37 papers matching the query expression. 对于 Year 属性,有 3 个非重复值,自 2013 年以来每年一个。For the Year attribute, there are 3 distinct values, one for each year since 2013. 3 个非重复值的论文总计数为 37。The total paper count over the 3 distinct values is 37. 对于每个 Year ,直方图显示值、自然对数总概率和匹配实体的数量。For each Year, the histogram shows the value, total natural log probability, and count of matching entities.

Keyword 的直方图显示有 34 个非重复关键字。The histogram for Keyword shows that there are 34 distinct keywords. 由于论文可以与多个关键字相关联,因此总计数 (53) 可以大于匹配实体的数量。As a paper may be associated with multiple keywords, the total count (53) can be larger than the number of matching entities. 虽然有 34 个非重复值,但由于“count=4”参数,响应仅包括前 4 个。Although there are 34 distinct values, the response only includes the top 4 because of the "count=4" parameter.

{
  "expr": "And(Composite(Author.Name=='jaime teevan'),Y>=2013)",
  "num_entities": 37,
  "histograms": [
    {
      "attribute": "Y",
      "distinct_values": 3,
      "total_count": 37,
      "histogram": [
        {
          "value": 2014,
          "logprob": -6.894,
          "count": 15
        },
        {
          "value": 2013,
          "logprob": -6.927,
          "count": 12
        },
        {
          "value": 2015,
          "logprob": -7.082,
          "count": 10
        }
      ]
    },
    {
      "attribute": "Keyword",
      "distinct_values": 34,
      "total_count": 53,
      "histogram": [
        {
          "value": "crowdsourcing",
          "logprob": -7.142,
          "count": 9
        },
        {
          "value": "information retrieval",
          "logprob": -7.389,
          "count": 4
        },
        {
          "value": "personalization",
          "logprob": -7.623,
          "count": 3
        },
        {
          "value": "mobile search",
          "logprob": -7.674,
          "count": 2
        }
      ]
    }
  ]
}