How to get the list of Managed Properties using code

using Microsoft.Office.Server;
using Microsoft.Office.Server.Administration;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Administration;

namespace ConsoleApplication1
{
    class Program
    {
        private static ServerContext serverContext = null;
        private static SearchContext searchContext = null;

        static void Main(string[] args)
        {
            string sharedServiceName = "SharedServices";
            serverContext = ServerContext.GetContext(sharedServiceName);
            searchContext = SearchContext.GetContext(serverContext);

            Schema schema = new Schema(searchContext);
            foreach (ManagedProperty prop in schema.AllManagedProperties)
            {
                Console.WriteLine(prop.Name);
            }
        }
    }
}

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.