-1

查看twitter数据库的“id”字段:

thufir@dur:~/flwor$ 
thufir@dur:~/flwor$ basex
BaseX 9.0.1 [Standalone]
Try 'help' to get more information.
> 
> open twitter
Database 'twitter' was opened in 218.67 ms.
> 
> xquery //id
<id type="number">1224165280068382720</id>
<id type="number">60919433</id>
<id type="number">1224160851797643264</id>
<id type="number">60919433</id>
..
<id type="number">14248074</id>
Query executed in 268.13 ms.
> 

我如何从FLWOR语句中得到相同的结果?

thufir@dur:~/flwor$ 
thufir@dur:~/flwor$ cat id.xq 

for $tweets in db:open("twitter")
let $tweet := $tweets
return <results>{$tweet}</results>

thufir@dur:~/flwor$ 

它将所有内容包装在<result>标签中,但仍提供每个节点。如何选择“id”节点?尝试变化:

  let $tweet := $tweets/id

没有积极的结果。也许是因为JSON混合在一起?

4

1 回答 1

0

雪花ID:

thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ basex tweetID.xq 
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>
<tweet>
  <id__str>1224165280068382720</id__str>
</tweet>
<tweet>
  <id__str>1224160851797643264</id__str>
</tweet>
<tweet>
  <id__str>1224134565280862208</id__str>
</tweet>
<tweet>
  <id__str>1224133755562086406</id__str>
</tweet>
<tweet>
  <id__str>1224117426364846081</id__str>
</tweet>
<tweet>
  <id__str>1224113562777419777</id__str>
</tweet>
<tweet>
  <id__str>1224083010015956992</id__str>
</tweet>
<tweet>
  <id__str>1224080221663645697</id__str>
</tweet>
<tweet>
  <id__str>1224042214541496320</id__str>
</tweet>
<tweet>
  <id__str>1224041056024645632</id__str>
</tweet>
<tweet>
  <id__str>1224036122344534017</id__str>
</tweet>
<tweet>
  <id__str>1224017759132143616</id__str>
</tweet>
<tweet>
  <id__str>1224016596634603520</id__str>
</tweet>
<tweet>
  <id__str>1224001430417297410</id__str>
</tweet>
<tweet>
  <id__str>1223987662094249991</id__str>
</tweet>thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ cat tweetID.xq 
for $tweets  in db:open("twitter")
return <tweet>{$tweets/json/id__str}</tweet>
thufir@dur:~/flwor/twitter$ 
thufir@dur:~/flwor/twitter$ 

FLWOR: _

for $tweets  in db:open("twitter")
return <tweet>{$tweets/json/id__str}</tweet>
于 2020-02-04T05:03:11.560 回答