AnsweredAssumed Answered

Additional fields with GET:/globalsearch

Question asked by john Fieldsend on Apr 12, 2020
Latest reply on Apr 14, 2020 by john Fieldsend

Hi all Im trying to customise the results returned with i run a globalsearch on the KBContents my test query in postman is 

{{localURL}}globalsearch?q=how%20do&module_list=KBContents&max_num=10&offset=10

this returns records and an example record below

            "id": "f425382c-0a18-11ea-bfce-020683bef092",
            "name": "How do I replace the printhead?",
            "date_entered": "2019-11-18T15:34:47+00:00",
            "date_modified": "2019-11-27T11:17:51+00:00",
            "modified_user_id": "fcba5520-b8f2-11e9-81b8-066c2def7d44",
            "created_by": "fcba5520-b8f2-11e9-81b8-066c2def7d44",
            "description": "",
            "kbdocument_body": "How do I replace the printhead?",
            "language": "en",
            "exp_date": "",
            "status": "published",
            "active_rev": 1,
            "is_external": 0,
            "commentlog": {
                "records": [],
                "next_offset": {
                    "commentlog_link": -1
                }
            },
            "locked_fields": [],
            "team_set_id": "1",
            "acl_team_set_id": "",
            "assigned_user_id": "fcba5520-b8f2-11e9-81b8-066c2def7d44",
            "_acl": {
                "fields": {}
            },
            "attachment_list": [],
            "_module": "KBContents",
            "_score": 35.51826,
            "_highlights": {
                "name": [
                    "<strong>How</strong> <strong>do</strong> I replace the printhead?"
                ],
                "kbdocument_body": [
                    "<strong>How</strong> <strong>do</strong> I replace the printhead?"
                ]
            }
        },

 

thats great but id also like to return the viewcount, iuseful and notuseful fields as well as some custom fields if possible

Searching the forum i found a few posts and tried  adding the following files to see the viewcount

 

custom/Extension/modules/KBContents/Ext/Vardefs/custom/customGlobalSearchFields.php

<?php

$dictionary['KBContents']['fields']['viewcount']['unified_search'] = true;


?>

 

custom/modules/KBContents/metadata/SearchFields.php

<?php

$searchFields['KBContents']['viewcount'] = array( 'query_type'=>'default');

?>

 

 I then did a refresh rebuild and went to admin->search and requested a reindex of the Knowledge base module. However the viewcount still does not show when i query the globalsearch endpoint with postman.

 

Anyone help with getting these additional fields returned

Outcomes