SharePoint KQL with custom managed metadata properties in Office365

This is a quick guide on how to set it up from the office 365 SharePoint admin center and test is with CSOM.
In order to access the custom managed properties we have to add them under SharePoint -> SharePoint admin center -> Manage Search Schema.

Velin Georgiev blog image

You simply add your new managed property and associate it with the crawled property.

Velin Georgiev blog image

so when the next search crawl is finished you can get it via CSOM keyword query. The newly created property should look like this in the managed properties list:

Velin Georgiev blog image

Then your CSOM C# code should look like this:

KeywordQuery keywordQuery = new KeywordQuery(clientContext);
                    keywordQuery.QueryText = "path:\" Rules\" AND ContentType:Item";
                    keywordQuery.ClientType = "CSOM";
                    SearchExecutor searchExecutor = new SearchExecutor(clientContext);
                    ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);

If the crawl is finished you should be able to see the results from your new managed property associated with site/list column:

Velin Georgiev blog image
Posted on

Tags: SharePoint, Office365, CSOM, KeywordQuery, Provider-hosted app, CSharp, SharePoint search, managed properties, crawled properties mapping, kql