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

evaluate 方法evaluate Method

evaluate 方法根据索引数据,计算并返回结构化查询表达式的输出。The evaluate method evaluates and returns the output of a structured query expression based on the index data.

表达式通常是通过响应 interpret 方法获得。Typically, an expression will be obtained from a response to the interpret method. 不过,也可以自己编写查询表达式(请参阅结构化查询表达式)。But you can also compose query expressions yourself (see Structured Query Expression).

请求Request

http://<host>/evaluate?expr=<expr>&attributes=<attrs>[&<options>]

名称Name Value 描述Description
exprexpr 文本字符串Text string 选择索引实体子集的结构化查询表达式。Structured query expression that selects a subset of index entities.
attributesattributes 文本字符串Text string 要在响应中包含的属性的逗号分隔列表。Comma-delimited list of attributes to include in response.
计数count 数字(默认值为 10)Number (default=10) 要返回的结果数上限。Maximum number of results to return.
offsetoffset 数字(默认值为 0)Number (default=0) 要返回的第一个结果的索引。Index of the first result to return.
orderbyorderby 文本字符串Text string 用于对结果排序的属性的属性名,后跟可选排序顺序(默认值为 asc):“attrname [:(asc|desc)]”。Name of attribute used to sort the results, followed by optional sort order (default=asc): "attrname[:(asc|desc)]". 如果未指定,返回按自然对数概率降序排列的结果。If not specified, the results are returned by decreasing natural log probability.
timeouttimeout 数字(默认值为 1000)Number (default=1000) 超时(以毫秒为单位)。Timeout in milliseconds. 仅返回在超时前计算出的结果。Only results computed before the timeout has elapsed are returned.

使用 count 和 offset 参数,可以通过多个请求以递增方式获取大量结果。Using the count and offset parameters, a large number of results may be obtained incrementally over multiple requests.

响应 (JSON)Response (JSON)

JSONPathJSONPath 描述Description
$.expr$.expr 请求中的 expr 参数。expr parameter from the request.
$.entities$.entities 一组与结构化查询表达式匹配的 0 个或多个对象实体。Array of 0 or more object entities matching the structured query expression.
$.aborted$.aborted 如果请求超时,则为 True。True if the request timed out.

每个实体都包含 logprob 值,以及请求获取的属性值。Each entity contains a logprob value and the values of the requested attributes.

示例Example

在学术出版物示例中,下面的请求传递结构化查询表达式(可能来自 interpret 请求输出),并检索前 2 个匹配实体的几个属性:In the academic publications example, the following request passes a structured query expression (potentially from the output of an interpret request) and retrieves a few attributes for the top 2 matching entities:

http://<host>/evaluate?expr=Composite(Author.Name=='jaime teevan')&attributes=Title,Y,Author.Name,Author.Id&count=2

响应包含前 2 (“count=2”) 个最佳匹配实体。The response contains the top 2 ("count=2") most likely matching entities. 对于每个实体,都会返回标题、年份、作者姓名和作者 ID 属性。For each entity, the title, year, author name, and author ID attributes are returned. 请注意,复合属性值结构与数据文件中指定的方式一致。Note how the structure of composite attribute values matches the way they are specified in the data file.

{
  "expr": "Composite(Author.Name=='jaime teevan')",
  "entities": 
  [
    {
      "logprob": -6.645,
      "Ti": "personalizing search via automated analysis of interests and activities",
      "Y": 2005,
      "Author": [
        {
          "Name": "jaime teevan",
          "Id": 1968481722
        },
        {
          "Name": "susan t dumais",
          "Id": 676500258
        },
        {
          "Name": "eric horvitz",
          "Id": 1470530979
        }
      ]
    },
    {
      "logprob": -6.764,
      "Ti": "the perfect search engine is not enough a study of orienteering behavior in directed search",
      "Y": 2004,
      "Author": [
        {
          "Name": "jaime teevan",
          "Id": 1982462162
        },
        {
          "Name": "christine alvarado",
          "Id": 2163512453
        },
        {
          "Name": "mark s ackerman",
          "Id": 2055132526
        },
        {
          "Name": "david r karger",
          "Id": 2012534293
        }
      ]
    }
  ]
}