ropensci / rentrez

talk with NCBI entrez using R
https://docs.ropensci.org/rentrez
Other
194 stars 38 forks source link

Order of the ids in entrez_search sorted in a different way than web search #191

Closed AdeFouchier closed 1 year ago

AdeFouchier commented 1 year ago

I'm trying to look for compounds in pccompound.

When I'm searching via the webinterface, it seems that results are sorted by "plausibility", at least the best match appear as the first.

Using entrez_search , the ids appears to sorted in a different way, probably by decreasing numerical value.

Is there any way to obtain the ids sorted with the best match being the fist id in the ids vector ?

Reproducible example :

 rentrez::entrez_search(db = "pccompound",
                                       term = "linalool",
                                       retmax = 99999)$ids
# Best match (cid : 6549) appearing last

https://www.ncbi.nlm.nih.gov/pccompound/?term=linalool Best match (cid : 6549) appearing first

AdeFouchier commented 1 year ago

A little break and a different approach in searching a solution to my problem allowed to find what I needed.

You should add a "sort = relevance" argument to the entez_search.

 rentrez::entrez_search(db = "pccompound",
                                       term = "linalool",
                                       sort = "relevance",
                                       retmax = 99999)$ids
# Best match (cid : 6549) appearing last