Discussion:
[Wikidata] order of results: API vs. Website
Raveesh Meena
2018-11-30 17:12:18 UTC
Permalink
Hi,

The search results obtained by these two approaches are ordered differently:

method1: using the wikidata API
<https://www.wikidata.org/w/api.php?action=help&modules=main>
https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Maruti&language=en

method2: search on wikidata Page
<https://www.wikidata.org/w/index.php?search=&search=&title=Special%3ASearch&go=Go>
https://www.wikidata.org/w/index.php?search=&search=Maruti&title=Special%3ASearch&go=Go

Intrestingly, in method2, the search suggestion drop-down list has the same
order as that of method1 (see screenshot).

q1. How can I obtain results in the same order as that of method2 using the
wikidata API (i.e., method 1).

q2. Which of the two ordering is in general more "relevant/accurate/better"

Thanks for any help/hints.

Best regards,
Raveesh
Lucas Werkmeister
2018-11-30 17:38:08 UTC
Permalink
wbsearchentities is a Wikibase-specific API; the normal MediaWiki search
function uses a different search configuration, which you can query in
the API via:

action=query&generator=search&gsrsearch=SEARCHTERM&gsrnamespace=0|120

For example:

https://www.wikidata.org/w/api.php?action=query&generator=search&gsrsearch=maruti&gsrnamespace=0|120&formatversion=2

Note that you need to sort the result list by the 'index' of each result
(I’m not sure why the API doesn’t do that for you).

Cheers,
Lucas
Post by Raveesh Meena
Hi, 
method1: using the wikidata API
<https://www.wikidata.org/w/api.php?action=help&modules=main> 
https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Maruti&language=en
method2: search on wikidata Page
<https://www.wikidata.org/w/index.php?search=&search=&title=Special%3ASearch&go=Go>
https://www.wikidata.org/w/index.php?search=&search=Maruti&title=Special%3ASearch&go=Go
Intrestingly, in method2, the search suggestion drop-down list has the
same order as that of method1 (see screenshot).
q1. How can I obtain results in the same order as that of method2
using the wikidata API (i.e., method 1).
q2. Which of the two ordering is in general more
"relevant/accurate/better"
Thanks for any help/hints.
Best regards,
Raveesh
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
Antonin Delpeuch (lists)
2018-11-30 20:18:20 UTC
Permalink
By the way, what is the difference between this "gsrsearch" and the
"srsearch" parameter from the docs?

https://www.wikidata.org/w/api.php?action=help&modules=query%2Bsearch
The documentation only mentions "srsearch" but the example is formulated
with "gsrsearch".

Antonin
Post by Lucas Werkmeister
wbsearchentities is a Wikibase-specific API; the normal MediaWiki search
function uses a different search configuration, which you can query in
action=query&generator=search&gsrsearch=SEARCHTERM&gsrnamespace=0|120
https://www.wikidata.org/w/api.php?action=query&generator=search&gsrsearch=maruti&gsrnamespace=0|120&formatversion=2
Note that you need to sort the result list by the 'index' of each result
(I’m not sure why the API doesn’t do that for you).
Cheers,
Lucas
Post by Raveesh Meena
Hi, 
method1: using the wikidata API
<https://www.wikidata.org/w/api.php?action=help&modules=main> 
https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Maruti&language=en
method2: search on wikidata Page
<https://www.wikidata.org/w/index.php?search=&search=&title=Special%3ASearch&go=Go>
https://www.wikidata.org/w/index.php?search=&search=Maruti&title=Special%3ASearch&go=Go
Intrestingly, in method2, the search suggestion drop-down list has the
same order as that of method1 (see screenshot).
q1. How can I obtain results in the same order as that of method2
using the wikidata API (i.e., method 1).
q2. Which of the two ordering is in general more
"relevant/accurate/better"
Thanks for any help/hints.
Best regards,
Raveesh
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
Lucas Werkmeister
2018-12-01 00:35:47 UTC
Permalink
The "g" prefix is because I used the generator version of the API,
because I’m not familiar enough with the non-Wikibase parts of the
MediaWiki API :) With list=search instead of generator=search, you use
"srsearch" instead. (By the way, the API Sandbox [1] makes all this much
easier to figure out.)

Cheers, Lucas

[1]: https://www.wikidata.org/wiki/Special:ApiSandbox
Post by Antonin Delpeuch (lists)
By the way, what is the difference between this "gsrsearch" and the
"srsearch" parameter from the docs?
https://www.wikidata.org/w/api.php?action=help&modules=query%2Bsearch
The documentation only mentions "srsearch" but the example is formulated
with "gsrsearch".
Antonin
Post by Lucas Werkmeister
wbsearchentities is a Wikibase-specific API; the normal MediaWiki search
function uses a different search configuration, which you can query in
action=query&generator=search&gsrsearch=SEARCHTERM&gsrnamespace=0|120
https://www.wikidata.org/w/api.php?action=query&generator=search&gsrsearch=maruti&gsrnamespace=0|120&formatversion=2
Note that you need to sort the result list by the 'index' of each result
(I’m not sure why the API doesn’t do that for you).
Cheers,
Lucas
Post by Raveesh Meena
Hi, 
method1: using the wikidata API
<https://www.wikidata.org/w/api.php?action=help&modules=main> 
https://www.wikidata.org/w/api.php?action=wbsearchentities&search=Maruti&language=en
method2: search on wikidata Page
<https://www.wikidata.org/w/index.php?search=&search=&title=Special%3ASearch&go=Go>
https://www.wikidata.org/w/index.php?search=&search=Maruti&title=Special%3ASearch&go=Go
Intrestingly, in method2, the search suggestion drop-down list has the
same order as that of method1 (see screenshot).
q1. How can I obtain results in the same order as that of method2
using the wikidata API (i.e., method 1).
q2. Which of the two ordering is in general more
"relevant/accurate/better"
Thanks for any help/hints.
Best regards,
Raveesh
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
_______________________________________________
Wikidata mailing list
https://lists.wikimedia.org/mailman/listinfo/wikidata
Loading...