Skip to content

[ENH] Allow for use of ES Multisearch feature where you can send multiple searches in one connection, to save on connections to ES on a page with many LIST plugins or nested plugins especially, includes [ENH] Allow caching of LIST wiki-plugins

NOTE that this merge request contains (squashed) changes that was made for this other merge request: !65 (commits), as it was done on top of it.

Sometimes we have a lot of LIST plugins on one page, especially if they are nested you are going to have a lot in total. If each one makes their own connections to the ES server, it very quickly adds up to a lot of connections and results in slow performance.

To get around this, one way is to make use of Elasticsearch's multisearch feature (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) to bundle all of the queries from different LIST plugins to query all at one go at the "top of the page", but instead of rendering the output, we save the results sent back from ES for rendering further down the page. Our tests show a significant improvement in performance, e.g. a page that took 4 sec to load can now only take 2 sec.

To implement this, you need to add a LIST plugin at the top of your output template (whether wiki page template or Smarty template) that uses {MULTISEARCH(id=x)}...{MULTISEARCH} blocks to contain the queries to bundle. Then you have your LIST plugins as usual for rendering the search results, but set multisearchid=x as a parameter for the LIST plugin. This instructs it to retrieve and format the search results that have already been returned, rather than to conduct it's own search.

Here is an example. Imagine you have a page that loads themes, say 20 of them, and for each of them you show the 4 latest created resources from that theme.

The "top" list plugin like this:

{LIST()} {filter type="trackeritem"} {filter field="tracker_id" exact="5"} {sort mode="tracker_field_order_asc"} {output template="resources-theme-results.tpl" result=$results} {LIST}

Attached is the resources-theme-results.tpl for your reference.

resources-theme-results.tpl

@jonnybradley as you were tagged on the other one too.

Edited by Nelson Ko

Merge request reports