私は自分の問題を解決しました。まず、マッピングを使って管理プロパティを作成しました。このlinkからソリューションにアクセスできます。
public void CreateManagedProperty()
{
// Get the default service context
SPServiceContext context = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);// Get the search service application proxy
var searchProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;
// Get the search service application info object so we can find the Id of our Search Service App
if (searchProxy != null)
{
SearchServiceApplicationInfo ssai = searchProxy.GetSearchServiceApplicationInfo();
// Get the application itself
var application = SearchService.Service.SearchApplications.GetValue<SearchServiceApplication>(ssai.SearchServiceApplicationId);
// Get the schema of our Search Service Application
var schema = new Schema(application);
// Get all the managed properties
ManagedPropertyCollection properties = schema.AllManagedProperties;
// Add a new property
ManagedProperty myProperty = properties.Create(Constants.ManagedPropertyName, ManagedDataType.Text);
myProperty.EnabledForScoping = true;
// Get the current mappings
MappingCollection mappings = myProperty.GetMappings();
// Add a new mapping to a previously crawled field
var myMapping = new Mapping(
new Guid(Constants.CrawledPropertyGuid), Constants.CrawledPropertyName, 31, myProperty.PID);
// Add the mapping
mappings.Add(myMapping);
// Update the collection of mappings
myProperty.SetMappings(mappings);
// Write the changes back
myProperty.Update();
}
}
次に、管理プロパティが拡張検索プロパティに追加されました。
public void AddAdvancedSearchProperty()
{
string sourcefile =
string.Format(
"{0}\\{1}", SPUtility.GetGenericSetupPath("TEMPLATE\\ADMIN\\ManagedProperties"), "NewAdvancedSearchProperty.xml");
// Load the xml file into XmlDocument object.
var xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(sourcefile);
}
catch (XmlException e)
{
Console.WriteLine(e.Message);
}
// Now create StringWriter object to get data from xml document.
var sw = new StringWriter();
var xw = new XmlTextWriter(sw);
xmlDoc.WriteTo(xw);
string newXmlString = sw.ToString();
using (var sc = new SPSite("YOUR SITE"))
{
using (SPWeb web = sc.OpenWeb("searchcentre"))
{
SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager("pages/advanced.aspx", PersonalizationScope.Shared);
foreach (var wp in mgr.WebParts)
{
if (wp is AdvancedSearchBox)
{
var asb = wp as AdvancedSearchBox;
asb.Properties = newXmlString;
mgr.SaveChanges(asb);
}
}
mgr.Web.Dispose();
}
}
}
注:忘れないでください!新しい管理プロパティを作成したら、フルクロールを開始します。