因此,我使用Javascript和JSON來試圖從JSON轉儲中檢索信息。我對JavaScript的使用經驗非常有限,但我很好奇如何用這些給定的查詢來過濾結果(從IBM Watson的發現演示中查詢和響應)。從多條件的Json轉儲中獲取信息
查詢
{
"count": 5,
"return": "title,enrichedTitle.text,url,host,blekko.chrondate",
"query": "\"uci\",language:english",
"aggregations": [
"nested(enrichedTitle.entities).filter(enrichedTitle.entities.type:Company).term(enrichedTitle.entities.text)",
"nested(enrichedTitle.entities).filter(enrichedTitle.entities.type:Person).term(enrichedTitle.entities.text)",
"term(enrichedTitle.concepts.text)",
"term(blekko.basedomain).term(docSentiment.type)",
"term(docSentiment.type)",
"min(docSentiment.score)",
"max(docSentiment.score)",
"filter(enrichedTitle.entities.type::Company).term(enrichedTitle.entities.text).timeslice(blekko.chrondate,1day).term(docSentiment.type)"
],
"filter": "blekko.hostrank>20,blekko.chrondate>1490425200,blekko.chrondate<1495695600"
}
響應
{
"companies": [
{
"key": "Reuters",
"matching_results": 23
},
{
"key": "Amgen Tour",
"matching_results": 14
},
{
"key": "Qatar Airways",
"matching_results": 13
},
{
"key": "AMC",
"matching_results": 10
},
{
"key": "British Cycling",
"matching_results": 10
},
{
"key": "HSBC UK",
"matching_results": 9
},
{
"key": "Track Cycling Worlds",
"matching_results": 9
},
{
"key": "Univision",
"matching_results": 8
},
{
"key": "Giro",
"matching_results": 6
},
{
"key": "BMC",
"matching_results": 5
}
],
"people": [
{
"key": "George Bennett",
"matching_results": 15
},
{
"key": "Vogel",
"matching_results": 12
},
{
"key": "Chris Taylor",
"matching_results": 11
},
{
"key": "Brent Bookwalter",
"matching_results": 10
},
{
"key": "Rachel Atherton",
"matching_results": 10
},
{
"key": "Barker",
"matching_results": 9
},
{
"key": "Russell Westbrook",
"matching_results": 9
},
{
"key": "John Coates",
"matching_results": 8
},
{
"key": "Tracey Gaudry",
"matching_results": 8
},
{
"key": "Laura Kenny",
"matching_results": 7
}
],
"topics": [
{
"key": "University of California, Irvine",
"matching_results": 44
},
{
"key": "Amgen",
"matching_results": 43
},
{
"key": "Tour of California",
"matching_results": 43
},
{
"key": "Track cycling",
"matching_results": 42
},
{
"key": "Bicycle",
"matching_results": 39
},
{
"key": "Giro d'Italia",
"matching_results": 37
},
{
"key": "World cup competition",
"matching_results": 37
},
{
"key": "Control premium",
"matching_results": 36
},
{
"key": "Irvine, California",
"matching_results": 36
},
{
"key": "Mergers and acquisitions",
"matching_results": 33
}
]
}
我猜測,響應部分來自JSON轉儲和查詢從中獲取信息。我試圖編寫一些代碼來過濾掉類似於上面列出的查詢的內容。我必須使用什麼格式從JSON轉儲中提取信息?
我試過四處尋找答案,但似乎這個查詢只是它周圍的代碼的一部分(更具體地說只是執行計算的代碼)而不是實際設置。
是否有我應該使用的方法?
我有JSON對象存儲到一個變量atm,它包含所有需要的信息。