SexyMF
SexyMF

Reputation: 11165

Wikipedia api search for text sort by relevancy

When I search in wiki UI for stack overflow I get different results from the API.
In the UI:
https://en.wikipedia.org/w/index.php?search=Stack+Overflow&title=Special%3ASearch&profile=advanced&fulltext=1&ns0=1

In the API:
https://en.wikipedia.org/w/api.php?action=query&origin=*&generator=search&prop=extracts&gsrsearch=Stack%20Overflow&gsrlimit=20&exintro=1&explaintext=1&exchars=350&exlimit=20

The thing that I'm missing in the API is sort by relevancy.
How can that be achieved?

Upvotes: 2

Views: 202

Answers (1)

user15517071
user15517071

Reputation: 614

The API result in fact contains the relevancy ranking. It is hidden in the index property of each page. For example, the first result in the UI "Stack Overflow" has "index": 1,.

(Curiously, the pages are ordered correctly when search is used as a list, not a generator)

Upvotes: 2

Related Questions