2017-04-26 119 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結構的問題嗎?

感謝

回答