【问题标题】:In Watson Discovery, limiting "return"ed fields to aggregation values在 Watson Discovery 中,将“返回”字段限制为聚合值
【发布时间】:2017-09-24 10:14:08
【问题描述】:

对于 Discovery REST api,参数/参数“return”控制返回哪些字段。

如果我将这些参数传递给 API

  {
              "query": named_sector,
              "count": "10",
              "filter": filter_dates,
              "aggregation" : "term(docSentiment.type,count:3)"
    }
    my_query = discovery.query(my_disc_environment_id, my_disc_collection_id, qopts)
    print(json.dumps(my_query, indent=2))

我得到以下信息:

{
    "matching_results": 14779,
    "aggregations": [
        {
            "type": "term",
            "field": "docSentiment.type",
            "count": 3,
            "results": [
                {
                    "key": "positive",
                    "matching_results": 4212
                },
                {
                    "key": "negative",
                    "matching_results": 3259
                },
                {
                    "key": "neutral",
                    "matching_results": 152
                }
            ]
        }
    ],
    "results": [
        {
            "id": "6389715fe7e7f711e0bc09d4f1236639",
            "score": 1.3689895,
            "yyyymm": "201704",
            "url": "https://seekingalpha.com/article/4060446-valuation-dashboard-consumer-discretionary-update",
            "enrichedTitle": null,
            "host": "seekingalpha.com",
            "text": "Valuation Dashboard: Consumer Discretionary - Update\n\nSummary\n\nValuation metrics in Consumer Discretionary.\n\nEvolution since last month.\n\nA list of stocks loo ....

还有数千行。如何将输出限制到聚合部分?这是我更好地处理返回的 JSON 结构的问题吗?

谢谢

【问题讨论】:

    标签: watson watson-discovery


    【解决方案1】:

    如果将 count 参数更改为 0,则返回的 JSON 将仅包含聚合。

    此外,如果您使用 Discovery 网络工具,您可以在“返回的结果数(计数)”字段中输入 0。

    更多细节和例子可以在这里找到:https://www.ibm.com/watson/developercloud/doc/discovery/using.html#building-aggregations

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-21
      • 1970-01-01
      • 2018-06-13
      • 2019-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多