How to use the Zing search engine in a script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-16-2012 12:09 PM
Does anyone know how to use the Zing search engine in a script ? I would like to create some specific searches on knowledge.
Full text search can be done quite easily using the sample script below, but I would like to use the ranking abilities of Zing.
Tom
var item = new GlideRecord('kb_knowledge');
var search = 'laptop';
if (search.length != 0) {
item.addQuery('123TEXTQUERY321', search);
}
item.addQuery('active', 'true');
item.query();
while (item.next()) {
gs.log(item.number + ' - ' + item.short_description);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2015 08:46 AM
Hey Tom,
I ran into a similar question, did you ever find an answer to this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2016 06:58 AM
Hi,
I have also a need for this functionality, I have a requirement that we should be able to order by ranking/relevancy on a custom knowledge search, anyone any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2017 01:02 PM
Hello All,
If I understand what you guys are looking for, you are already on the right track with your GlideRecord query set up. The one remaining piece is the ir_query_score field that is added to every retrieved record. For example, the following will search Catalog Items for the term 'Application' and they will be sorted by strongest score to weakest automatically:
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('123TEXTQUERY321', 'Application');
gr.query();
while (gr.next()) {
gs.print(gr.name + ': ' + gr.ir_query_score);
}