Page MenuHomePhabricator

Create a search API that can return both search suggestions (like list=search) and extra article data from other API modules (like generator=search)
Closed, DeclinedPublic

Description

Example list query: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=eistein

Note the "searchinfo" JSON object that's returned inside the query object which contains metadata like number of search results, and the search suggestion.

Example generator query: https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=eistein

The searchinfo is not there, and we need it so our users can get the "did you mean" suggestions. :-(

There should be a single API that one can hit to do this. You can combine list=search and generator=search into a single query, but given that you get two sets of results back (unless you explicitly request only one, then discard it), this feels like a hack. We should have a proper solution.

Details

Event Timeline

• Deskana raised the priority of this task from to Needs Triage.
• Deskana updated the task description. (Show Details)

It's not a bug in the API either. A generator is supposed to generate a list of pages, not return all sorts of extra information.

It's not a bug in the API either. A generator is supposed to generate a list of pages, not return all sorts of extra information.

Given that a second API request to list=search specifically for this information is out of the question for performance reasons, how do you suggest we proceed? It seems there are two options:

  1. Make the generator return this extra information
  2. Make the list=search query also be able to provide the extra data that the generator can provide (e.g. descriptions from the PageTerms module)

Are there other options as well?

gerritbot subscribed.

Change 186942 had a related patch set uploaded (by BearND):
Enable search suggestions in full text search task

https://gerrit.wikimedia.org/r/186942

Patch-For-Review

Change 186942 merged by Dbrant:
Enable search suggestions in prefix search task

https://gerrit.wikimedia.org/r/186942

@Deskana, @Anomie : any further action required on this card, or can this be marked resolved?

I don't think this is resolved. We have a hack in the app that makes this work, but fundamentally it's still a hack.

I wrote this task with a specific solution in mind which I think @Anomie disagrees with, but really this is about a more generic problem and I don't really mind what the solution is.

Let me reword the title.

• Deskana renamed this task from generator=search API should return information about search suggestions, like list=search does to Create a search API that can return both search suggestions (like list=search) and extra article data from other API modules (like generator=search).Feb 11 2015, 5:08 PM
• Deskana updated the task description. (Show Details)

With the reworded description, I'm going to close this as Declined now.

This is a regression. The API used to work, but searchinfo was removed, which broke my code.

Do the MediaWiki developers announce non-backwards compatible changes to the API?

If there is a genuine reason why it isn't possible to include the searchinfo in the generator output then it should be included in the documentation here:

https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bsearch

If there is a genuine reason why it isn't possible to include the searchinfo in the generator output then it should be included in the documentation here:

https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bsearch

Generators generate a list of pages, they don't output extra data.

It's not up to the API help to explain design decisions.

The code that generates the API response has the totalhits information, but doesn't included it in the results. What's the harm in including it? For years, the value of totalhits was available via the search generator query, now it has been removed.

I will workaround the missing totalhits information by making a list=search request followed by a generator=search request.