RefinerConfiguration Interface

RefinerConfiguration Interface

SharePoint 2010

Represents the refiner configuration containing refiner settings for the managed property.

Namespace:  Microsoft.SharePoint.Search.Extended.Administration.Schema
Assembly:  Microsoft.SharePoint.Search.Extended.Administration (in Microsoft.SharePoint.Search.Extended.Administration.dll)

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public interface RefinerConfiguration

The refiner configuration manages refiner settings for textual and numeric managed properties.

The following code example enables refinement on a managed property


            using System;
            using Microsoft.SharePoint.Search.Extended.Administration;
            using Microsoft.SharePoint.Search.Extended.Administration.Schema;
             
            namespace EnableRefinerConfigurationSample
            {
                class Program
                {
                    static void Main(string[] args)
                    {
                        try
                        {
                            SchemaContext schemaContext = new SchemaContext();
                            Schema schema = schemaContext.Schema;
            
                            //Fetch the managed property named 'language'.
                            ManagedProperty managedProperty = schema.AllManagedProperties["language"];
            
                            //By default most managed properties are not enabled for refinement.
                            //The 'language' managed property is one of those and therefore needs to be enabled.
                            managedProperty.RefinementEnabled = true;
                            //Always remember to update the managed property after editing one of its properties.
                            //This will enable a refiner for this managed property.
                            managedProperty.Update();
            
                            RefinerConfiguration refinerConfiguration = managedProperty.GetRefinerConfiguration();
                            Console.WriteLine("Refiner Configuration" +
                                              "\n\tRefinementType = " + refinerConfiguration.RefinementType +
                                              "\n\tAnchoring = " + refinerConfiguration.Anchoring);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
            }
             

The following code example updates the refiner configuration on a


            using System;
            using Microsoft.SharePoint.Search.Extended.Administration;
            using Microsoft.SharePoint.Search.Extended.Administration.Schema;
             
            namespace UpdateRefinerConfigurationSample
            {
                class Program
                {
                    static void Main(string[] args)
                    {
                        try
                        {
                            SchemaContext schemaContext = new SchemaContext();
                            Schema schema = schemaContext.Schema;
            
                            //Fetch the managed property named 'size'.
                            ManagedProperty managedProperty = schema.AllManagedProperties["size"];
            
                            //The managed property named 'size' has refinement enabled by default,
                            //but let's make sure that it really is enabled
                            if (!managedProperty.RefinementEnabled)
                            {
                                managedProperty.RefinementEnabled = true;
                                managedProperty.Update();
                            }
            
                            //Fetch the refinement configuration of the managed property
                            RefinerConfiguration refinerConfiguration = managedProperty.GetRefinerConfiguration();
                            var oldResolution = refinerConfiguration.Resolution;
                            refinerConfiguration.Resolution = oldResolution * 2;
            
                            //To deploy the updated refiner configuration
                            managedProperty.SetRefinerConfiguration(refinerConfiguration);
                            //Note that it is not necessary to update the managedProperty itself: managedProperty.update()
            
                            Console.WriteLine("Refiner Configuration" +
                                              "\n\told resolution = " + oldResolution +
                                              "\n\tnew resolution = " + refinerConfiguration.Resolution);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }
            }
             
Show:
© 2016 Microsoft