Ayo
Ayo

Reputation: 49

How to retrieve content from Wikipedia for large lengthy queries?

I tried retrieving data from Wikipedia API using

url: "http://en.wikipedia.org//w/api.php?action=opensearch&format=json&search=" + searchvalue + "&limit=12"

where searchvalue is the value gotten from a textbox. My problem is that I get desired results when searchvalue = "the flash" but I get no results(empty arrays) when searchvalue = "the flash and the supergirl. How do I make calls to the API to retrieve articles containing any of the words searchvalue if no articles exist that match that title exactly. I'm trying to achieve something like this:

https://en.wikipedia.org/w/index.php?search=the+flash+and+the+supergirl&title=Special:Search&go=Go&searchToken=6wtdjlxknk7q715hkdp52cegf 

Upvotes: 0

Views: 65

Answers (1)

Andy
Andy

Reputation: 63524

You can use a boolean search:

Boolean search – All major search engines support the "-" character for "logical not", the AND, the OR, and the grouping parentheses brackets: (_). Logical OR must be spelled in capital letters; the AND operator is assumed for all terms (separated by spaces), but capital AND is equivalent. Parentheses are a necessary feature because: (blue OR red) AND green, differs from: blue OR (red AND green) -- Wikipedia documentation

So if you wanted to search for "The Flash" or "Supergirl" searchvalue would be: "the flash" or "supergirl".

Here's that query in action

Upvotes: 2

Related Questions