Document picker list limit / sort issue

I’ve been experimenting with using the org.xwiki.model.reference.DocumentReference document picker in macros, and I’m hitting a problem that may simply be due to my lack of understanding of the possibilities with this.

In short, when I want to pick a document root, I can’t when using the UI. See this example:
image

There are many pages under the root that I’m trying to pick (in this case, “OIT Knowledge Base”), and these show up instead of the actual page I’m trying to pick.

Is this a by-design limitation? Sorting problem?
FWIW, if I simply enter in the document reference text, it works marvelously, though I’m still unable to select it in the drop-down list. It would be a much better user experience if it were possible to select the page in the UI.

1 Like

Hi,

The document picker is using the Search REST resource to fetch suggestions. The request URL looks like this:

/xwiki/rest/wikis/xwiki/search?q=sandbox&scope=name&scope=title&number=10&localeAware=true&prettyNames=true

So the intention is to match the page name or its title. The implementation doesn’t properly match the page name though:

String matchTerminalPage = "doc.name <> :defaultDocName and upper(doc.fullName) like :keywords";
String matchNestedPage = "doc.name = :defaultDocName and upper(doc.space) like :keywords";

We’re basically matching:

  • the page full reference (without the wiki part) for terminal pages
  • the space full reference (without the wiki part) for nested pages

We should instead match:

  • the page name (last part of the reference) for terminal pages (easy, just have to replace doc.fullName with doc.name)
  • the last space name for nested paged (a bit more complex because we need to join the spaces table to be able to get the last space name)

I think this was already reported as Loading... .

Thanks,
Marius

1 Like

Btw, I often work around issues with the page picker by copying the “Page Reference” from the page’s “Information” tab and paste it in the page picker field directly. This works … most of the time, though of course it is not how the page picker is intended to be used.

Thanks @mflorea, I’m sure you’re right, as that issue exactly describes what we’re seeing. We’ll watch that and see what comes of it. :slight_smile:

@mflorea, is doc.title a good matching point? I’m still coming up to speed on the xwiki data structures, but it seems like that (with some execptions that may be important?) is the piece we’re generally wanting to match on

@lanedsmu there are two problems with doc.title:

  • it can be left empty, in which case the display falls back on doc.name for terminal pages and last space name for nested pages
  • it can contain Velocity code, usually for translating the page title, so if you search for the displayed title you might not find the page

This is why matching both doc.title and doc.name or the last space name is generally better.

Thanks,
Marius

Is this the same approach employed for the Page picker in the Insert link macro?

No, the page picker (suggester) used in the WYSIWYG editor link dialog is based on Solr search (rather than database search). See https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-ckeditor/xwiki-platform-ckeditor-plugins/src/main/webjar/xwiki-resource/entityResourceSuggester.js#L86 .It uses https://extensions.xwiki.org/xwiki/bin/view/Extension/Solr%20Search%20Application#HJSONService .

Hope this helps,
Marius

Thanks for the clarification :slightly_smiling_face:

For those keeping score, this appears to have been addressed --fixed-- in Loading....