Loading...
Skip to main content
Navigation and related functionality and content
Features
Requirements
Download
Install
Backup
Upgrade
Help
FAQs
Need Assistance ? Join-us live this Thursday, click for info !
Related content
Find
History: PluginList multisearch output control block
View published page
Source of version: 3
(current)
''Copied from [https://gitlab.com/tikiwiki/tiki/-/merge_requests/85|MR85] for Tiki 20'' 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 [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html|Elasticsearch's multisearch feature] 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 -+~np~{MULTISEARCH(id=x)}...{MULTISEARCH}~/np~+- 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: {CODE(caption="Example wiki page" colors="tiki" theme="default")}{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}{CODE} {CODE(caption="Example resources-theme-results.tpl output template file" colors="smarty" theme="default")}{wikiplugin _name=list} {foreach $results as $result} {literal} {MULTISEARCH(id="{/literal}resources-{$result@key}{literal}")} {pagination max=4} {filter type="trackeritem"} {filter field="tracker_id" exact="7"} {filter field="tracker_field_resourceTheme" multivalue="{/literal}{$result.tracker_field_themeCategory_text}{literal}"} {sort mode="creation_date_desc"} {MULTISEARCH} {/literal} {/foreach} {/wikiplugin} {foreach $results as $result} <div class="row"> <div class="resource-item-container" id="theme-{$result.tracker_field_themeCategory_text}"> <div class="resource-header clearfix"> <a href="resources-by-theme?theme_id={$result.tracker_field_themeCategory_text}"> <h4 class="pull-left"> {$result.tracker_field_name} </h4> </a> <a href="resources-by-theme?theme_id={$result.tracker_field_themeCategory_text}" class="pull-right view-all">View all ></a> </div> <div class="resource-results card-container card-container-col-4"> {wikiplugin _name=list multisearchid="resources-{$result@key}"} {literal} {pagination max=4} {filter type="trackeritem"} {filter field="tracker_id" exact="7"} {filter field="tracker_field_resourceTheme" multivalue="{/literal}{$result.tracker_field_themeCategory_text}{literal}"} {sort mode="creation_date_desc"} {output template="resources-results.tpl"} {ALTERNATE()} <div class="resource-results" style="margin-left:10px;" No resources under this theme yet. </div> {ALTERNATE} {/literal} {/wikiplugin} </div> </div> </div> {/foreach} {CODE} !!All the LIST Plugin control blocks {toc pagename="PluginList"}
Related content