Silvan_WMDE added subscribers: Ladsgroup, Silvan_WMDE. Silvan_WMDE added a comment.
Conveniently, the first of the two example requests from the mobile app demonstrates how to combine both the file name prefix search and the general search in a single request: ?format=json&formatversion=2&errorformat=plaintext&action=query&redirects=&converttitles=&prop=description|pageimages|info&piprop=thumbnail&pilicense=any&!!generator=prefixsearch!!&gpsnamespace=0&!!list=search!!&srnamespace=0&inprop=varianttitles&srwhat=text&srinfo=suggestion&srprop=&sroffset=0&srlimit=1&pithumbsize=320&!!gpssearch=Barcelonnette!!&gpslimit=20&!!srsearch=Barcelonnette!! Note the combination of `search=list` with `srsearch=<searchterm>` and `generator=prefixsearch` with `gpssearch=<searchterm>` parameters. The option to combine several of the available query modules //"to get what you need in one request"// is even documented in the action=query API documentation <https://www.mediawiki.org/wiki/API:Query#Additional_notes>. Currently, our `search=list` approach triggers a response that has the list of results in a `query.search` array: https://commons.wikimedia.org/w/api.php?format=json&action=query&list=search&srnamespace=6&srlimit=10&srsearch=Barcelonnette%20-%20Villa%20du%20Parc%20du%20Mercantour%20-986.jpg { "batchcomplete": true, "query": { "searchinfo": { "totalhits": 10 }, "search": [ { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -984.jpg", [...] }, { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -985.jpg", [...] }, [...] { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -986.jpg", [...] } ] } } Modifying the request so that it addresses both the `list=search` and the `generator=prefixsearch` modules, will trigger a response with results in two sections, `query.pages` and `query.search`: https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&prop=description%7Cpageimages%7Cinfo&piprop=thumbnail&pilicense=any&generator=prefixsearch&gpsnamespace=6&inprop=varianttitles&gpssearch=Barcelonnette%20-%20Villa%20du%20Parc%20du%20Mercantour%20-986.jpg&gpslimit=1&list=search&srnamespace=6&srlimit=10&srsearch=Barcelonnette%20-%20Villa%20du%20Parc%20du%20Mercantour%20-986.jpg { "batchcomplete": true, "query": { "pages": [ { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -986.jpg", [...] } ], "searchinfo": { "totalhits": 10 }, "search": [ { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -984.jpg", [...] }, { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -985.jpg", [...] }, [...] { "ns": 6, "title": "File:Barcelonnette - Villa du Parc du Mercantour -986.jpg", [...] } ] } } So here's our one-size-fits-all request which is answered with both the exact filename prefix-match and the general search results in a single response. We would only have to adjust the way results are being processed and possibly ignore the exact file name match from the list of search results, so that it doesn't show up twice. Also, a decision has to be made by product (@Lydia_Pintscher?) on the `gpslimit` parameter (for prefix search) and the `srlimit` one (for general search), as to how many results do we expect back for each of the two searches. An easy way to do it is probably `gpslimit=1` and `srlimit=10`, then reduce the second one to 9 items if there is in fact an exact file name match. On the other hand, mobile app apparently does `srlimit=1` and `gpslimit=20` in the first example above, for whatever reasons. To support such decisions, ideally we could use some data from the backend, how people are actually using the P18 box: do we generally see more search terms (possibly with search syntax?) or more values that look like file names? @Ladsgroup? TASK DETAIL https://phabricator.wikimedia.org/T245589 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Silvan_WMDE Cc: Silvan_WMDE, Ladsgroup, Lydia_Pintscher, Addshore, dcausse, Aklapper, darthmon_wmde, Nandana, Lahi, Gq86, GoranSMilovanovic, QZanden, LawExplorer, _jensen, rosalieper, Scott_WUaS, Jonas, Wikidata-bugs, aude, Mbch331
_______________________________________________ Wikidata-bugs mailing list Wikidata-bugs@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs