2017-04-26 71 views
0

对于Discovery REST API,参数/参数“return”控制返回哪些字段。在Watson Discovery中,将返回ed字段限制为汇总值

所以,如果我通过这些参数传递给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结构的问题吗?

感谢

回答