Page MenuHomePhabricator

Build the Vue.js search component network client
Closed, ResolvedPublic5 Estimated Story Points

Description

This is a skeletal task for implementing a network client for the new search Desktop Improvements Project / FAWG search experience. The interface approach taken by Popups (RESTBase / Action ) seems to have worked well and allows the underlying service to be swapped between the Action API, RESTBase, and mocked data so it should probably be considered for this task.

Questions

  • Is the caching sensible? For example, if a user types "f", "o", "o", <backspace>, can the browser served cached results for "fo"?
  • Do we need an A/B test for the network clients?
  • What types are nullable, undefined, or missing? It's not yet documented as far as I can tell.
  • What behavior do we want for submission? Portals uses //wikipedia.org/search-redirect.php, wikis use /w/index.php. The former lands on https://en.wikipedia.org/w/index.php?cirrusUserTesting=glent_m0&search=no+matching+query&title=Special%3ASearch&go=Go&ns0=1 and he latter lands on https://en.wikipedia.org/wiki/Special:Search?search=no+matching+query&go=Go&ns0=1. Matches (including redirects) go to the page on both.

Docs and examples

Acceptance criteria

  • Compare to the Action API and Portals implementation.
  • DWIM works or a task or spike for how to support it is made. See T262566.
  • Search implementation is compatible with WVUI browser targets.

Related Objects

StatusSubtypeAssignedTask
OpenNone
OpenNone
OpenNone
OpenNone
Resolvedovasileva
ResolvedVolker_E
Resolvedphuedx
Resolved eprodromou
ResolvedEvanProdromou
ResolvedPeter.ovchyn
ResolvedPeter.ovchyn
ResolvedPeter.ovchyn
Resolved eprodromou
ResolvedPeter.ovchyn
Resolveddaniel
Resolveddaniel
Resolveddaniel
Resolved holger.knust
Resolved holger.knust
Resolved holger.knust
OpenNone
OpenNone
OpenNone

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Niedzielski added a subscriber: holger.knust.

Assigning to @holger.knust to track follow-up on result order.

@holger.knust, please also verify with @eprodromou what the intended CORS operation is.

We'd like to use the new production REST APIs in our demos and development outside of Wikimedia domains. For example, https://en.wikipedia.org/w/rest.php/v1/search/title?q=foo. For the Action API, we would enable more permissive server response headers by adding the origin=* parameter. Is there a similar mechanism for the MediaWiki REST API?

I also wasn't sure if it would be possible to search from fr.wikipedia.org, for example, from en.wikipedia.org.

@eprodromou any update for us on CORS or result order? We'd love to use the new REST API in the new search experience. /cc @holger.knust

ovasileva set the point value for this task to 5.Jul 15 2020, 4:36 PM

PR: https://github.com/wikimedia/wvui/pull/72

Not sure if we need the excerpt field but the search/title endpoint seems to always return the title in the excerpt property:

https://en.wikipedia.org/w/rest.php/v1/search/title?q=the%20rebel&limit=3

{
    "pages": [
        {
            "id": 52294167,
            "key": "The_Rebel_(South_Korean_TV_series)",
            "title": "The Rebel (South Korean TV series)",
            "excerpt": "The Rebel (South Korean TV series)",
            "description": "television series",
            "thumbnail": {
                "mimetype": "image/jpeg",
                "size": null,
                "width": 133,
                "height": 200,
                "duration": null,
                "url": "//upload.wikimedia.org/wikipedia/en/thumb/8/85/Poster_for_Thief_Who_Stole_the_People.jpg/133px-Poster_for_Thief_Who_Stole_the_People.jpg"
            }
        },
        {
            "id": 29730098,
            "key": "The_Rebel_Flesh",
            "title": "The Rebel Flesh",
            "excerpt": "The Rebel Flesh",
            "description": "episode of Doctor Who",
            "thumbnail": null
        },
        {
            "id": 5308866,
            "key": "The_Rebel_(TV_series)",
            "title": "The Rebel (TV series)",
            "excerpt": "The Rebel (TV series)",
            "description": "TV series",
            "thumbnail": {
                "mimetype": "image/jpeg",
                "size": null,
                "width": 150,
                "height": 200,
                "duration": null,
                "url": "//upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Nick_Adams_The_Rebel.JPG/150px-Nick_Adams_The_Rebel.JPG"
            }
        }
    ]
}

I'm tempted to remove it from the internal TypeScript interface.

I've noticed that the Accept-Language header doesn't seem to make a difference. So, not sending it at this time.

Thank you, @bearND. Please file bug reports against the MediaWiki-REST-API for any issues encountered.

This is blocked, as we are waiting for core support from @eprodromou.

I think @holger.knust cleared the blockers already 🍾. The problem with CORS was settled here T232176, and the problem with search results differing is here T258736. Are there other outstanding issues?

@eprodromou It doesn't seem to work yet. Running the following in the dev console from any website other than https://en.wikipedia.org triggers the CORS error because the Access-Control-Allow-Origin header is not present in the response:

fetch('https://en.wikipedia.org/w/rest.php/v1/search/title?q=cat').then(response => response.json()).then(data => console.log(data));

Access to fetch at 'https://en.wikipedia.org/w/rest.php/v1/search/title?q=cat' from origin 'https://developer.mozilla.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

@eprodromou, it sounds like CORS is expected to be working but @bearND is having trouble with it. Can you help?

ovasileva raised the priority of this task from Medium to High.Sep 9 2020, 5:09 PM

Hey @Niedzielski and @ovasileva , @EvanProdromou mentioned it should be working now. Can someone from our team check on the search endpoint?

It works now. :) Now we can use this for development as well.

Niedzielski added subscribers: nick_ras, bearND.

Thank you, @bearND! @nick_ras is going to tackle the remaining work which is to add support for canceling requests.

Change 629093 had a related patch set uploaded (by Nick Raskin; owner: Nick Raskin):
[wvui@master] Update network client

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

Change 630652 had a related patch set uploaded (by Nick Raskin; owner: Nick Raskin):
[wvui@master] Update network client, fix comments

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

Change 631247 had a related patch set uploaded (by Nick Raskin; owner: nick-ras):
[wvui@master] Rewrite async/await to .then(), fix typo.

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

Change 629093 abandoned by Nick Raskin:
[wvui@master] Update network client

Reason:

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

Change 629093 restored by Jdrewniak:
[wvui@master] Update network client

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

Change 630652 abandoned by Jdrewniak:
[wvui@master] Update network client, fix comments

Reason:
These changes have been merged into https://gerrit.wikimedia.org/r/c/wvui/ /629093

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

Change 631247 abandoned by Jdrewniak:
[wvui@master] Rewrite async/await to .then(), fix typo.

Reason:
These changes have been merged into https://gerrit.wikimedia.org/r/c/wvui/ /629093

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

Change 632568 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[wvui@master] Implement FetchJsonReturn type

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

Change 632568 merged by jenkins-bot:
[wvui@master] Implement FetchJsonReturn type

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

Change 635375 had a related patch set uploaded (by Nray; owner: Nray):
[wvui@master] Delete actionSearchClient and associated tests

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

Change 635375 merged by jenkins-bot:
[wvui@master] Delete actionSearchClient and associated tests

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

Change 629093 merged by jenkins-bot:
[wvui@master] Add ability to abort fetch requests

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

This now needs to be integrated with the wvui-typeahead-search component.

nray subscribed.

Change 636752 had a related patch set uploaded (by Nray; owner: Nray):
[wvui@master] [typeahead-search] Abort the last request (if any) on new input

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

This now needs to be integrated with the wvui-typeahead-search component.

I've pushed https://gerrit.wikimedia.org/r/636752 and am moving this back to needs code review since the integration is pretty small, and I'd rather handle that as part of this ticket rather than create a new ticket.

Change 636752 merged by jenkins-bot:
[wvui@master] [typeahead-search] Abort the last request (if any) on new input

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

phuedx claimed this task.

Being bold.