7

When I perform full-text search with Wikipedia API, I can not narrow it to titles only (srwhat=title).

So while search anywhere (default) http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=sql&srnamespace=14&format=xml

returns results, if I add srwhat=title, I got an error:

<api servedby="mw69">
  <error code="srsearch-title-disabled" info="title search is disabled"/>
</api>

This error is even listed in the docs ( http://www.mediawiki.org/wiki/API:Search ), but without any explanation.

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
Maksee
  • 2,311
  • 2
  • 24
  • 34
  • It seems there is a way to workaround this. See this answer: http://stackoverflow.com/questions/27624431/wikipedia-api-search-titles-generator – Damjan Pavlica Oct 20 '15 at 19:37
  • [opensearch](https://en.wikipedia.org/w/api.php?action=help&modules=opensearch) is a good alternative – John Strood Jul 27 '18 at 08:44

2 Answers2

7

Actually, there is a way to workaround this, just add intitle: prefix to your search term:

srsearch=intitle:sql

You can find an explanation here: https://en.wikipedia.org/wiki/Help:Searching#Parameters

Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
3

It means that the search engine Wikipedia uses (Lucene, I believe) does not support title search.

svick
  • 236,525
  • 50
  • 385
  • 514
  • You mean, there are features planned in the API that could not be supported due to particular engine used? – Maksee Jan 15 '13 at 18:06
  • 2
    MediaWiki is not just Wikipedia. Other wikis don't use Lucene, so they can support title search. But Wikipedia doesn't. – svick Jan 15 '13 at 18:37
  • 2
    Thanks, looking at the searching help, I also found that I can use the same operators in the search (so "intitle:" should help) so no problem with not supporting titles directly – Maksee Jan 15 '13 at 20:06