IR_AND_OR_QUERY in service portal search source

michal_v
Giga Contributor

Hey,

We are using Service Portal on Istanbul and we are trying to change the search method in the service catalog search source.

the original script was:

var sc = new GlideRecord('sc_cat_item');

sc.addQuery('123TEXTQUERY321', query);

sc.addQuery('active',true);

sc.addQuery('no_search', '!=', true);

sc.addQuery('visible_standalone', true);

sc.addQuery('sys_class_name', 'NOT IN', 'sc_cat_item_wizard');

var portalValue = $sp.getValue('sc_catalog');

if (portalValue)

sc.addQuery('sc_catalogs', portalValue);

sc.query();

I change the line sc.addQuery('123TEXTQUERY321', query) to:

sc.addQuery('IR_AND_OR_QUERY', query);

but I still don't get the OR part, for instance:

I have 2 items with the following description:

item 1: Ariba Spend Visibility (SV) is a web-based solution for indirect and direct global spend analysis. It helps users to have visibility into spending, make more insightful sourcing decisions, and identify more ways to cut costs.

item 2: Ariba Procure To Pay (P2P) is a platform for managing upstream and downstream procurement processes. It's a cloud based application, shared globally in order to enable savings, increase efficiency, and allow global visibility of indirect spend. Ariba is integrated to a back-end ERP system. It includes sourcing, contract and supplier performance management, and advanced Procure-to-Pay processes.

when I search for Global insight I expect to get both of them (I have global in both) but I got only item 1 (it has global and insightful).

Can any one explain why?

3 REPLIES 3

Shiraz2
Mega Guru

See if the following can help you. It has a section on "OR" Query.



https://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/


richardchadd
ServiceNow Employee
ServiceNow Employee

hello i do not think a simple OR condition will meet the requirement.



Michal is trying to perform a text search "IR_AND_OR_QUERY" for records indexed for the words "global" AND/OR "insight".



it seems to be performing only the AND operation and therefore excluding the cat items do not have the word "insight" in the description.



see following about text searching from script:



Full Text Searches in Service Portal - ServicePortal.io - Service Portal Tutorials, Widgets, & Theme...



Search OperatorDescription
IR_AND_QUERYDisplay results with exact matches of all terms only (Same as 123TEXTQUERY321)
IR_OR_QUERYDisplay results with any matches of any terms.
IR_AND_OR_QUERYFirst display results with exact matches of all terms, then display results with any matches of any terms


using "IR_OR_QUERY" will give the records as required eg. record indexed for the word "global" or the word "insight".



however that does not explain why "IR_AND_OR_QUERY" is only performing the AND and excluding OR operation when making the text search in Michal's case. Further research would be required.


Replying over to old thread as it may help others to understand how the IR_AND_OR_QUERY works. And probably that is the reason why michal_v getting 1 result.

The IR_AND_OR_QUERY executes according to its name:

  1. Execute IR_AND_QUERY
  2. Check number of results against glide.ts.query.and_or_limit property or text_search_and_or_limit table attribute
  3. If # of results is greater
    1. Return results
  4. If # of results is less than
    1. Execute IR_OR_QUERY and return results