0

I'm preforming a query search using Wikipedia API, but the results I'm getting don't seem to be very relevant, unless the search term is exact.

So, for example, when I'm searching for "Pink floy" using the following get request, I would expect to get "Pink Floyd" as the first result, but I'm not getting it (at all):

https://en.wikipedia.org/w/api.php?explaintext=1&pithumbsize=100&exsentences=1&list=+prefixsearch&format=json&pilimit=max&generator=search&exintro=1&redirects=1&prop=pageimages%7Cextracts&gsrnamespace=0&action=query&gsrsearch=pink%2Bfloy

Using Opensearch the results make much more sense, if I'm using the following link: https://en.wikipedia.org/w/api.php?format=json&action=query&list=allpages&apprefix=pink%20floy

The problem is that in Opensearch I don't get the extra information I need.

Is there a way to get the results like in Opensearch, but getting all the additional info as I can get in query?

SuperFrog
  • 7,631
  • 9
  • 51
  • 81
  • When you search for `floy`, you will get results that are relevant for `floy`, rather than for `floyd`. Not sure what you expected there. If you want to do a prefix search, use the prefixsearch API. – Tgr Nov 29 '20 at 08:03
  • Looking at the [search results page](https://en.wikipedia.org/w/index.php?search=pink+floy) is maybe more self-explanatory. – Tgr Nov 29 '20 at 08:04
  • I understand what you're saying, though I didn't search for "floy", but for "Pink Floy". Is there a way to get the same information (extract, image) using the prefixsearch API? – SuperFrog Nov 29 '20 at 18:34
  • 1
    Yes, it can be used as a generator, same as the search API. `generator=prefixsearch`, `gpsnamespace` instead of `gsrnamespace` etc. – Tgr Nov 29 '20 at 23:45
  • Thank you so much! It helped me a lot. I would be happy to mark this as an answer if you'll add it. – SuperFrog Nov 30 '20 at 00:25

0 Answers0