2

I am using SP2010 and spservices jquery library to make sql search queries to the search service. I created a managed metadata called DocumentGUID which is mapped to the document guid crawled property. I ran a full crawl and when I try this query, the result contains no field for the DocumentGUID. I did some research and found these:

https://stackoverflow.com/questions/2293066/how-do-i-perform-a-moss-fulltextsqlquery-and-filter-people-results-by-the-skills

SP 2010 FullTextSqlQuery display managed properties in query results

It seems I need to enable them. So from the first link, I am trying this c# console app, that will do it for me, but I am getting errors with the code.

These two

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

are not being found....

Does anyone know how to fix this?

Thanks.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search.Administration;

namespace FixManagedMetaData
{
    class Program
    {
        static void Main(string[] args)
        {


        }

        private void EnsureFullTextQueriableManagedProperties(ServerContext serverContext)
        {
            var schema = new Schema(SearchContext.GetContext(serverContext));
            var managedProperties = new[] { "DocumentGUID" };
            foreach (ManagedProperty managedProperty in schema.AllManagedProperties)
            {
                if (!managedProperties.Contains(managedProperty.Name.ToUpper()))
                    continue;

                if (managedProperty.FullTextQueriable)
                    continue;

                try
                {
                    managedProperty.FullTextQueriable = true;
                    managedProperty.Update();
                    Console.WriteLine("Successfully set managed property {0} to be FullTextQueriable: " + managedProperty.Name);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error updating managed property {0}: " + managedProperty.Name);
                }
            }
        }


    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.