Compartilhar via


ManagedProperty.Weight property

NOTE: This API is now obsolete.

Obtém ou define a configuração de peso para uma propriedade gerenciada.

Namespace:  Microsoft.Office.Server.Search.Administration
Assembly:  Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)

Syntax

'Declaração
<ObsoleteAttribute("This property is deprecated. It does not take effect on ranking, please use RankingModel class.")> _
Public Property Weight As Single
    Get
    Set
'Uso
Dim instance As ManagedProperty
Dim value As Single

value = instance.Weight

instance.Weight = value
[ObsoleteAttribute("This property is deprecated. It does not take effect on ranking, please use RankingModel class.")]
public float Weight { get; set; }

Property value

Type: System.Single
Um número de ponto flutuante, de precisão dupla que especifica o valor do peso para uma propriedade gerenciada no esquema de pesquisa.

Comentários

A configuração de peso se aplica à estrutura de relevância e afeta a importância relativa de uma propriedade gerenciada durante o cálculo de classificação.

Para obter mais informações sobre relevância em SharePoint Enterprise Search, consulte Enterprise Search Relevance Architecture Overview e Improving Relevance.

Examples

O exemplo de código a seguir altera a configuração de peso para uma propriedade gerenciada. Para uma explicação passo a passo do código usado neste exemplo, consulte How to: Change the Weight Setting for a Managed Property.

Prerequisites

Certifique-se de que um provedor de serviços compartilhados já foi criado.

Project References

Adicione as seguintes referências de projeto em seu projeto de código de aplicativo de console antes de executar este exemplo:

  • Microsoft.SharePoint

  • Microsoft.Office.Server

  • Microsoft.Office.Server.Search

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

namespace PropertyWeightSample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                if (args.Length != 2)
                {
                    Usage();
                    return;
                }

                /*
                Replace <SiteName> with the name of a site using the Shared Service Provider.
                */
                string strURL = "http://<SiteName>";
                Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
                ManagedPropertyCollection properties = sspSchema.AllManagedProperties;

                string strPropertyName = args[0].ToLower();
                float newWeight = Convert.ToSingle(args[1]);

                if (!properties.Contains(strPropertyName))
                {
                    Console.WriteLine(strPropertyName + " property does not exist.");
                    return;
                }

                foreach (ManagedProperty property in properties)
                {
                    if (property.Name.ToLower() == strPropertyName)
                    {
                        property.Weight = newWeight;
                        Console.WriteLine("Weight value changed for " + strPropertyName + " property.");
                        Console.WriteLine("NAME: " + property.Name + "  WEIGHT: " + property.Weight.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Usage();
            }
        }

        private static void Usage()
        {
            Console.WriteLine("Change Property Weight");
            Console.WriteLine("Usage: PropertyWeightSample.exe ManagedPropertyName <WeightValue>");
            Console.WriteLine("<WeightValue>: Must be formatted as a float.");
        }
    }
}

Ver também

Referência

ManagedProperty class

ManagedProperty members

Microsoft.Office.Server.Search.Administration namespace