I have been doing a ton of search work lately and just wanted to share a useful script for tracking down those pesky Managed Property Values. I have been wanting to write a search series, but just can’t seem to find the time to put pen to paper (or fingers to keyboard in my case) to get them written up!
When I first started working with search I think my biggest headache was to tell which managed properties were being retrieved and what the values were for each managed property. The below script can be added to your display template to log the managed property name & value to your console window for each search result returned.
This code can be implemented within any display template, but for this example I will be using the Item_CommonItem_Body display template
(NOTE after your test you should remove the code snippet due to compatibility issues for some browser versions & that there really isn’t a reason to log these values to console outside of testing) I am using this particular template as an example, but any display template which is called from search could be used.
Below is the default code from Body tag of our Item_Common_Body display template where I have added the script to iterate through the managed properties.
Now that we have added the script, saved and published the display template we are ready to see what is brought back from our search results!
- Open your browser’s developer tools
- i.e. FireBug, Chrome Tools, F12, etc.
- Enter a search query into the search box which will return results
- You can use * to grab everything
- Select the console tab in your developer tools
- Bask in the awesome... There are actually more properties for this particular item than the screenshot shows, but I can only grab so many with a screen capture :)
Hope This Helps!