Why does filtering on doc title in a livetable not work as expected?

Last modified by Clemens Robbenhaar on 2018/10/23

Use case

Before XWiki 10.9 when a livetable is created with doc.title as a column, by default that column did not show as filterable. Since XWiki 10.9 the filtering field appears but typing in it might show results where the page title has a little footnote symbol and a note is displayed at the table footer that "filtering and sorting by title will not work as expected for these pages". On the other hand the property doc.location can be used and filtered as expected. The reason for this behavior is explained below.


There are two different things that usually act as "title", doc.title and doc.displayTitle. The first one is an actual metadata field of the document, persisted to the database, while the latter is a dynamic field computed from different sources, including the doc.title field, headers in the content, the document name, and other fields selected by the sheet used to display the objects in the document. Plus, it could even be more dynamic, as in text generated by some Velocity code, in the most basic form a translation.

Livetable filters work directly on the database, meaning that they translate into sql conditions ("and doc.title like '%text introduced by the user%'"). The doc.title Livetable column is special, since it's not exactly the doc.title metadata, but a combination of doc.title and doc.displayTitle, so even though the computed display title is displayed, filtering and sorting works on the internal title (the one stored as metadata). Given the very dynamic and unpredictable aspect of the display title, it's impossible to write a correct sql filter that would match the display title in all cases.

For this reason filtering by title won't meet the user's expectations: it doesn't filter on the displayed title, but on the internal title. In these cases where both titles are not the same, the note mentioned above is displayed to inform users that their expectations will not be met for these pages.
What's more, it can't be configured so that it filters on the right information all the time. For certain instances it would be possible to actually make the field filterable, but only when the documents displayed by the Livetable really use the document title as the only source of the displayed title.

For example, if you edit some of the displayed documents in wiki or wysiwyg mode and enter something in the document title field (the one above the content), and the content does not contain something dynamic like velocity code, you will be able to filter it in the livetable as expected.

Get Connected