fabiobatalha / crossrefapi

A python library that implements the Crossref API.
BSD 2-Clause "Simplified" License
280 stars 44 forks source link

result rank #24

Closed CNGaoWenbo closed 4 years ago

CNGaoWenbo commented 4 years ago

Are results ranked in a row? If I search the same key words in different number in 'sample()', how can I get different results in the second time?

For example, works.query(bibliographic=key_words).sample(10), get 10 results. Then works.query(bibliographic=key_words).sample(20), how to get new 20 results instead 10 old and 10 new.

Thanks!

fabiobatalha commented 4 years ago

@CNGaoWenbo

This is the way the Crossref API works when using sample.

the sample endpoint retrieve a random corpus of data. The results are not ranked.

If you want to have the first 10 records you should remove sample() and iterate in the results until you have the desired number of records.

ex:

count = 0
for item in works.query(bibliographic=key_words):
  count +=1
  if count >= 10:
    break