SearchServiceApplication.AddContextValueFromKeyForTuningQuery method

SharePoint 2013

Adds a context value for the given TuningQuery. A context refers to any property in a query and each property has a dynamically allocated ID. In this method only two properties are used: the user issuing the query (UserId) and the user’s language (LanguageId). The dynamically allocated ID may be 0 or 1.

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

public int AddContextValueFromKeyForTuningQuery(
	SearchObjectOwner searchObjectOwner,
	int QueryId,
	string ContextKey,
	string ContextVal


Type: Microsoft.Office.Server.Search.Administration.SearchObjectOwner

The owner of the search site hierarchy.

Type: System.Int32

The tuning query; a query that you can use to customize the ranking model.

Type: System.String

The context key; either “LanguageId” or “UserId”.

Type: System.String

The context value.

Return value

Type: System.Int32
The result. 0 indicates successful; -1 indicates an error.

Use this method if you know the key of your property, e.g. UserId or LanguageId. Otherwise, use AddContextValueFromIdForTuningQuery().

Typically if there are multiple users and multiple queries, the most common user or query will be chosen. A TuningQuery can only have 1 user and 1 language.