ManagedProperty.Weight - Propriété

Remarque : cette API est désormais obsolète.

Obtient ou définit le paramètre poids d'une propriété gérée.

Espace de noms :  Microsoft.Office.Server.Search.Administration
Assembly :  Microsoft.Office.Server.Search (dans Microsoft.Office.Server.Search.dll)

Syntaxe

'Déclaration
<ObsoleteAttribute("This property is deprecated. It does not take effect on ranking, please use RankingModel class.")> _
Public Property Weight As Single
    Get
    Set
'Utilisation
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; }

Valeur de propriété

Type : System.Single
Un double précision nombre à virgule flottante qui spécifie la valeur de poids d'une propriété gérée dans le schéma de recherche.

Remarques

Le paramètre de poids s'applique à l'infrastructure de pertinence et a un impact sur l'importance relative d'une propriété gérée lors du calcul de classement.

Pour plus d'informations sur la pertinence dans Recherche de contenu d’entreprise SharePoint, voir Enterprise Search Relevance Architecture Overview et Improving Relevance.

Exemples

L'exemple de code suivant modifie le paramètre de poids d'une propriété gérée. Pour une procédure pas à pas du code utilisé dans cet exemple, voir How to: Change the Weight Setting for a Managed Property.

Prerequisites

Vérifiez qu'un fournisseur de services partagés est déjà créé.

Project References

Ajoutez les références de projet suivantes dans le projet de code d'application console avant d'exécuter cet exemple :

  • 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.");
        }
    }
}

Voir aussi

Référence

ManagedProperty classe

ManagedProperty - Membres

Microsoft.Office.Server.Search.Administration - Espace de noms