How to make partial pattern matches in keyword queries?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 02:05 PM
Hello all,
As the question states, I was wondering if there is a way to make partial pattern matches for keyword queries using GlideRecord?
Let's say I have records/text like:
Apple
Orange
Apple and Orange
I know that if I do something like
gr.addQuery("123TEXTQUERY321", keyword);
I have to match the entire word for a result for a result to show up, and if I make keyword something that is a partial match, like
gr.addQuery("123TEXTQUERY321", "Appl");
no results will show. Is there a way to get results back using partial matches and if so, what is the best way?
I've tried using wildcards like *keyword and keyword* but that doesn't really solve my issue because there are cases like searching the last X digits of a record's number field where the result won't show up. Individually, these also don't help the partial matching issue either. Querying Appl* helps with the partial matching issue but it doesn't help if the query is for the last X digits of a record's number field (000001* isn't going to return results for RITM0000001). And switching from keyword* to *keyword just switches the type of queries that won't show up.
/*
Example records
RITM0000001 - Oranges
TASK0000001 - Apples
*/
// keyword*
gr.addQuery("123TEXT321", "Appl*")
// TASK0000001 - Apples appears
// RITM0000001 - Oranges doesn't appear
gr.addQuery("123TEXTQUERY321", "0000001*")
// Nothings appears
// *keyword
gr.addQuery("123TEXTQUERY321", "*Appl");
// Nothing appears
gr.addQuery("123TEXTQUERY321", "*0000001");
// TASK0000001 appears
// RITM0000001 appears
I've also tried doing things like *keyword* but I get an error message saying how the wildcards are too ambiguous/too many results (or something like that).
Is there any way to achieve partial pattern matching when querying keywords? Or do I have to resort to some type of workaround?
- Labels:
-
Search
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2022 05:05 AM
Hi,
I am looking for similar functionality, but the above code is not working for 'dmn_demand' table, Is there anything I am missing.