When searching the knowledge base, the text search query to find results is executed twice. This occurs in the kb_find_query UI Macro. After the query is built, it is passed into the KnowledgeSection2 tag, which adds limits for pagination and executes the query. Then the query is executed again directly in kb_find_query. It looks like there is an if/else condition around the second direct query in order to only execute when pagination is not enabled, but the condition for the else is commented out.

Note: jvar_apply_paging is always true. It is set in the kb_find UI page directly, and kb_find_query is never included anywhere else.

This issue has been present since at least Aspen. It appears to have been introduced in 76ce5d6ddbedc1a1fe4830a539dee833fbb5ca35 from 2011-01-11, which added pagination to Knowledge search results.

Steps to Reproduce

  1. Log in to a ServiceNow instance.
  2. Enable Debug Text Search.
  3. Go to Knowledge.
  4. Conduct a general search.

There will be two query debug outputs, each from START Strategy Analysis to Total Time for Text Query.


This issue is caused by the fact that the com.glideapp.knowledge_section record tag executes the query, and the explicit kb.query(); below it as well, resulting in the query being run twice. The fix (and the workaround) is to edit the kb_find_query UI Macro and update the (last section of the) XML to look like this: 


<j2:if test="$[jvar_apply_paging == 'true']">
<g2:com.glideapp.knowledge_section record="$[kb]" startRecord="$[sysparm_current_row - 1]"
endRecord="$[sysparm_current_row + sys_nav_count - 1]"/>
<j2:if test="$[jvar_apply_paging == 'false']">
// When pagination is enabled, the query will be executed in
// the knowledge_section above. When disabled, we need to run
// it here instead:

Related Problem: PRB587149

Seen In

Eureka Patch 4 Hot Fix 3
Eureka Patch 9 Hot Fix 4

Fixed In

Calgary Patch 2 Hot Fix 12
Calgary Patch 4
Dublin EA 5

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2015-08-23 09:28:06