Community Wishlist Survey 2022/Wikisource/Search in books

Search in books

  • Problem: When books are transcluded into many pages, it is difficult to search text in them. For example, if I want to search Ajax in the Iliad, I must open 24 transclusions (Iliad/Canto I, Iliad/Canto II, etc.) and make a text search in every page; another solution, but which is barely known even by contributors of Wikisource, would be using the advanced search, namely its field "Subpages of this page". To remedy this, some contributors create a new page with the full text of the book : Iliad/Full text. I think it would be more useful to provide a search bar in every page of the main namespace which allows to find text in the current page or in all subpages.
  • Proposed solution: Provide a search bar on every page of the main namespace, giving results in the current page or in the whole book. In a word, this search bar would search text exactly in the same pages as the ones exported by the Export button. More precisely, it might be inserted next to the Export button, at the very top of the page, and may function in a similar way: if the Export button enables to export only the current page, the search bar reads « Search in this page » and gives the same results as Ctrl+F/Cmd+F; but when the Export button enables to export the whole book, the search bar reads « Search in full book ».
  • Who would benefit: ::Readers: on French Wikisource, the full text page of famous books (like Candide by Voltaire) are more read than the individual transclusions, because readers consult these books on Wikisource mainly for full text search.
Editors: we could save time if we stopped creating full text pages, which often have problems (too many templates, broken links, etc.)
  • More comments: Idea of improvement : enabling regular expressions in this search bar (which is impossible with Ctrl+F: it would then justify the presence of this search bar in every page).
  • Phabricator tickets: task T309490
  • Proposer: ElioPrrl (talk) 10:14, 14 January 2022 (UTC)

Discussion

But transcluded pages does not contain the text of the book. In Iliad/Canto I, there is not "The wrath of Peleus' son etc.", but <pages index="Homer - Iliad, translation Pope, 1909.djvu", etc.. And even if it would, for the average user, use prefixes, keywords, etc., is not easy. On every page of Gallica (webpage of the French National Library) or Internet Archive, when you consult a book in their portal, there are two search bar: the first one for searching in the whole website, the second one (commonly integrated in the book viewer) for searching the book. — ElioPrrl (talk) 12:31, 17 January 2022 (UTC)
Your use case above does not adequately explain what you're trying to explain to me then, because I still don't get why searching in wikitext doesn't get you what you want. Izno (talk) 19:26, 17 January 2022 (UTC)
@Izno:: Are you used to Wikisource? In Wikisource, the text of a page is rarely contained in the wikitext, but is transcluded from another page. Example : this transclusion only contains <pages index="Homer - Iliad, translation Pope, 1909.djvu" from=35 to=51 />, a command that transcludes the text containes in this page and the following ones; and note that the reader normally never accesses the Page: namespace. Therefore, even when restricting results to subpages of a given page, using insource: to search transclusions of a book would not give any result: give it a try! In fact, the results are better without this parameter.
Anyway, this a very complicated way, only known by contributors, not by the average user. In the same way, it is possible, on IA or the BnF, to use the advanced search to find words in a given book; but all users of IA and BnF search books not this way, but by using the search bar integrated in the book viewer. I ask to emulate this functioning in Wikisource: a search bar integrated to transclusions. I advise you to consult SWilson's first solution below to understand what I mean. — ElioPrrl (talk) 09:55, 18 January 2022 (UTC)
  • It's actually sort of already possible to put a search box in the 'indicators' area (where the export button is). Here's a hacky version: https://en.wikisource.beta.wmflabs.org/wiki/Test_Book — although, it's only possible to set a prefix to search, rather than following all the rules that WS Export uses (e.g. finding subpages referenced within ws-summary sections). I'm not sure of the best way around that, because it'd be really slow to determine what the extent of the work is (and even then it's still not foolproof), but we could think about adding a 'search' button next to export which would display a search dialog with some more info and the search form. —SWilson (WMF) (talk) 06:08, 17 January 2022 (UTC)
 Thanks! You have completely understood my thought. No matter if the first solution is not totally reliable: it's easier to urge developers into improving an existing tool than creating it from scratch. I only thought that, in order to save developer's time, the lines of code used in WSexport to select the pages to be exported could be reused for this new purpose, but maybe it's not feasible. — ElioPrrl (talk) 12:31, 17 January 2022 (UTC)
The prefix parameter would be basepagename, not fullpagename. The intent is to searh pages with the same base page. Other than that, excellent.--Snævar (talk) 07:10, 20 January 2022 (UTC)
@SWilson (WMF) and Snævar: I can also notice that sometimes the books may have transclusions whose title does not begin with the title of the base page. In particular, in French Wikisource, sometimes the complete works of an author are transcluded under their different titles; for example, in the book whose table of contents is found in Complete Works of Molière, the different plays are transcluded in the pages Tartufe, Don Juan, etc., not Complete Works of Molière/Tartufe, Complete Works of Molière/Don Juan (this is something I criticise on French Wikisource, but the very major part of the contributors still creates pages this way, because of this issue: they are afraid that under the long title the readers could not find the page, and they don't want to waste their time creating redirections to prevent this). — ElioPrrl (talk) 12:02, 4 February 2022 (UTC)
  • @ElioPrrl, maybe I did not understand every aspect of your question, but look at a random ns0 page in it.wikisource, e.g. this Iliad: under the header you can see a search box available also by the layman to have a full search of a word in the entire work (here is the result for Aiace). Is this what you asked for? - εΔω 08:18, 4 February 2022 (UTC)
@OrbiliusMagister: It is indeed what I am asking for. It seems that it is added automatically by your template Intestazione, doesn't it ? It would be nice if it could be added automatically on every page of ns0, even those without any template. — ElioPrrl (talk) 12:04, 4 February 2022 (UTC)
@ElioPrrl: helping other users is my pleasure. On it.source the search box is actually an embedded Template:Ricerca, but you may just help yourself with it in many projects. - εΔω 20:13, 4 February 2022 (UTC)

Voting