Forum Discussion
How to find out the weight context of all Managed Properties
Hi there
I have a situation where I need to get the Context weight group of each managed property in our SPO tenant. I was hoping there was a way to get this with a Powershell script or some sort of hidden download option but I am not seeing anything.
Does anyone know if there is a way to get this information without having to go into each Managed property?
This is all related to search results that are showing up in a weird order and we are thinking that someone changed the weight group on something but I am at a loss as to where they changed it. So just trying to find a way to figure that out.
Thanks in advance.
- michalkornetIron Contributor
Hi Mel_C13, Is it possible to set this setting in SP Online? I tried to test the possibility of getting this information yesterday, but after changing it from the UI and checking it again, I still see the default 'Context 0' value.
- Mel_C13Brass Contributor
michalkornet I have been able to change the Context in the Managed Properties area of the SharePoint Search Admin area. But where I am stuck is that I have over 4000 managed properties and I want to see which ones aren't Context 0 without having to go into each property.
I am hoping there is some sort of script that I can run to grab that info.
- michalkornetIron Contributor
Hi Mel_C13, I tested it once again on my tenant, and I am able to get this value by calling the page (
`https://${tenantName}-admin.sharepoint.com/_layouts/15/searchadmin/ta_managedproperty.aspx?property=${property}&level=tenant` )and then extracting it from the HTML. I think this is not the best solution, but it looks like it works.
The result looks like this ->
The code that should be executed on the admin site:
(async () => {const tenantName = 'Your tenant'const managedPropertyName = ['AADObjectID', 'AccountName'];for (let property of managedPropertyName) {const web = await fetch(`https://${tenantName}-admin.sharepoint.com/_layouts/15/searchadmin/ta_managedproperty.aspx?property=${property}&level=tenant`)const htmlResult = await web.text();const tempContainer = document.createElement('div');tempContainer.innerHTML = htmlResult;const inputElement = tempContainer.querySelector('#ctl00_ctl00_PlaceHolderContentArea_PlaceHolderMain_weightGroupHiddenTextBox');const weightGroupValue = inputElement['value'];console.log(`Managed Property: ${property} - WeightGroupValue ${weightGroupValue}`)}})().catch(console.log)Let me know if it works for you. To be honest, I still cannot edit these values on my tenant, so I hope the script does not return the default values for these properties.