Does the use of IR_OR_QUERY or IR_AND_OR_QUERY search each field in the table for the input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 01:25 PM
Let's say I have 5 records in sc_cat_item.
- 3 Records have the word Test in the Name field
- The other 2 records have Test in the Description field
If I have code such as the following. It appears to be searching all the fields in each record for the word 'Test'? And the results show 5 records. This is what I would expect to happen.
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('IR_OR_QUERY', 'Test');
gr.query();
while (gr.next()) { gs.print gr.name}
However, with the following code, I only get the 2 records returned that have the word 'Test' in the description field. And If I replace 'description' column below with the column 'meta'. I get 0 records returned.
Is this because the addOrCondition uses an exclusive OR?
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('description', 'CONTAINS', 'Test');
gr.addOrCondition('IR_OR_QUERY', 'Test');
gr.query();
while (gr.next()) { gs.print gr.name}
If I reverse the condition statements as follows, I get all 5 records
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('IR_OR_QUERY', 'Test');
gr.addOrCondition('description', 'CONTAINS', 'Test');
gr.query();
while (gr.next()) { gs.print gr.name}
Testing of the following took place in Vancouver Version although I believe the same behavior exists in Tokyo as well. Is this how the gliderecord handles conditions? Is there any documentation, that sheds some light on how these statements are logically processed in the background?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2024 01:49 PM
Hi @Renee-17 ,
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:
Search Operator Description
IR_AND_QUERY | Display results with exact matches of all terms only (Same as 123TEXTQUERY321) |
IR_OR_QUERY | Display results with any matches of any terms. |
IR_AND_OR_QUERY | First 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.
The IR_AND_OR_QUERY executes according to its name:
- Execute IR_AND_QUERY
- Check number of results against glide.ts.query.and_or_limit property or text_search_and_or_limit table attribute
- If # of results is greater
- Return results
- If # of results is less than
- Execute IR_OR_QUERY and return results
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda