在 SharePoint Server 中的查詢變數Query variables in SharePoint Server

摘要:了解您可以使用您在設定查詢時的查詢變數。Summary: Learn about the query variables that you can use when you configure a query.

查詢變數Query variables

下表顯示適用於 SharePoint Server,以及如何使用的範例查詢變數。The following tables show the query variables for SharePoint Server, and examples on how they can be used.

網站與網站集合的屬性Site and site collection properties

查詢變數Query variable 定義Definition
{Site} 或 {Site.URL}{Site} or {Site.URL}
發出查詢之網站的 URL。例如,此值可以用來查詢 Managed 屬性 Path 的內容。URL of the site from where the query was issued. For example, this value can be used to query content of the managed property Path.
{Site.ID}{Site.ID}
發出查詢之網站的 GUID。此值對應至 Managed 屬性 SiteID 的值。GUID of site from where the query was issued. This value corresponds to the value of the managed property SiteID.
{Site.LCID}{Site.LCID}
地區設定的數值,如同發出查詢之 [網站] 上 [網站設定] 中的 [地區設定] 所指定。Numeric value of the locale as specified by the Regional Settings in the Site Settings on the Site from where the query was issued.
{Site.Locale}{Site.Locale}
來自在 ll-cc 格式發出查詢之網站的語言-例如 en-us-我們。Language of the Site from where the query was issued in ll-cc format — for example, en-us.
{Site。<屬性>}{Site.<property>}
來自發出查詢之網站 (SPWeb) 的屬性包的任何屬性,包含自訂屬性。Any property from the property bag of the site (SPWeb) from where the query was issued, including custom properties.
{SiteCollection} 或 {SiteCollection.URL}{SiteCollection} or {SiteCollection.URL}
發出查詢之網站集合的 URL。例如,此值可以用來查詢 Managed 屬性 Path 的內容。URL of site collection from where the query was issued. For example, this value can be used to query content of the managed property Path.
{SiteCollection.ID}{SiteCollection.ID}
發出查詢之網站集合的 GUID。GUID of site collection from where the query was issued.
{SiteCollection.LCID}{SiteCollection.LCID}
地區設定的數值,如同發出查詢之 [網站集合] 上 [網站設定] 中的 [地區設定] 所指定。Numeric value of the locale as specified by the Regional Settings in the Site Settings on the Site Collection from where the query was issued.
{SiteCollection.Locale}{SiteCollection.Locale}
來自在 ll-cc 格式發出查詢之網站集合語言-例如 en-us-我們。Language of the Site Collection from where the query was issued in ll-cc format — for example, en-us.
{SiteCollection。<屬性>}{SiteCollection.<property>}
來自發出查詢之網站集合 (SPSite) 中根網站 (SPWeb) 的屬性包的任何屬性,包含自訂屬性。Any property from the property bag of the root site (SPWeb) in the site collection (SPSite) from where the query was issued, including custom properties.

頁面、 URL token、 查詢字串及要求屬性Page, URL token, query string and request properties

查詢變數Query variable 定義Definition
{Page} 或 {Page.URL}{Page} or {Page.URL}
發出查詢之頁面的 URL。例如,此值可以用來查詢 Managed 屬性 Path 的內容。URL of the page from where the query was issued. For example, this value can be used to query content of the managed property Path.
{Page.UsageAnalyticsId}{Page.UsageAnalyticsId}
使用分析的項目識別碼Item ID for Usage Analytics
{Page。<FieldName>}{Page.<FieldName>}
發出查詢之網頁上的欄位值。例如,如果發出查詢的頁面包含名為 "ContentOwner" 的網站欄,指定 {Page.ContentOwner} 便能允許您查詢 "ContentOwner" 的值。The value of a field on the page from where the query was issued. For example, if the page from where the query was issued contained a site column named "ContentOwner," specifying {Page.ContentOwner} would allow you to query for the value of "ContentOwner."
{URLToken。<整數>}{URLToken.<integer>}
從頁面的 URL 的值。整數代表計算從右至左的 URL 中值的位置。例如,為該頁面http://www.contoso/audio/mp3/1010101、 查詢變數 {URLToken.1} 會查詢 1010101 URL 的最後一個值。在 URL] 中的第三個最後一個屬性會查詢的查詢變數 {URLToken.3} 音訊。您可以查詢最多個 ULR 中的第九個最後一個位置的值。A value from the URL of a page. The integer represents the position of the value in the URL as counted from right to left. For example, for the page http://www.contoso/audio/mp3/1010101, the query variable {URLToken.1} will query for the last value in the URL, 1010101. The query variable {URLToken.3} will query for the third last property in the URL, audio. You can query for values up to the ninth last position in a ULR.
{QueryString。<ParameterName>}{QueryString.<ParameterName>}
目前頁面 URL 中查詢字串的值。例如,若目前頁面的 URL 包含像是 ItemNumber=567 的查詢字串,則您可以藉由指定 {QueryString.ItemNumber} 來獲得 567 這個值。A value from a query string in the URL of the current page. For example, if the URL of the current page contains a query string such as ItemNumber=567, you could obtain the value 567 by specifying {QueryString.ItemNumber}.
{要求。<PropertyName>}{Request.<PropertyName>}
目前 http 要求的值 - 例如 {Request.Url}。A value from the current http request - for example, {Request.Url}.

使用者屬性User properties

查詢變數Query variable 定義Definition
{User} 或 {User.Name}{User} or {User.Name}
發出查詢之使用者的顯示名稱。例如,此值可以用來查詢 Managed 屬性 Author 的內容。Display name of the user who issued the query. For example, this value can be used to query content of the managed property Author.
{User.Email}{User.Email}
發出查詢之使用者的電子郵件地址。例如,此值可以用來查詢 Managed 屬性 WorkEmail 的內容。Email address of the user who issued the query. For example, this value can be used to query content of the managed property WorkEmail.
{User.SID}{User.SID}
發出查詢之使用者的 SID。SID of the user who issued the query.
{User.LCID}{User.LCID}
地區設定的數值,如發出查詢之使用者的設定檔中所定義。Numeric value of locale as defined in the profile of the user who issued the query.
{User.PreferredContentLanguage}{User.PreferredContentLanguage}
如同發出查詢之使用者設定檔中 [慣用內容語言] 中指定的語言。Language as specified as Preferred Content Language in the profile of the user who issued the query.
{User.PreferredDisplayLanguage}{User.PreferredDisplayLanguage}
如同發出查詢之使用者設定檔中 [慣用顯示語言] 中指定的語言。Language as specified as Preferred Display Language in the profile of the user who issued the query.
{User。<屬性>}{User.<property>}
來自發出查詢之使用者的使用者設定檔的任何屬性 — 例如,Sps-interests,包括自訂屬性。Any property from the user profile of the user who issued the query — for example, SPS-Interests, including custom properties.

字詞和字詞組屬性Term and term set properties

查詢變數Query variable 定義Definition
{Term} 或 {Term.ID} 或 {Term.IDNoChildren}{Term} or {Term.ID} or {Term.IDNoChildren}
#0 首碼與目前網站瀏覽節點的 GUID — 例如 #083e99dcb-7907-4dc9-abc8-b5614a284f1c。例如,這個值可用來查詢的 managed 的屬性 owstaxIdMetadataAllTagsInfo 或 owstaxIdProductCatalogItemCategory 產品目錄網站集合中的內容。GUID of current site navigation node with a prefix of #0 — for example, #083e99dcb-7907-4dc9-abc8-b5614a284f1c. For example, this value can be used to query content of the managed property owstaxIdMetadataAllTagsInfo or owstaxIdProductCatalogItemCategory in a Product Catalog Site Collection.
{Term.IDWithChildren}{Term.IDWithChildren}
# 首碼與目前網站瀏覽節點的 GUID — 例如 #83e99dcb-7907-4dc9-abc8-b5614a284f1c。如此可傳回與目前網站的導覽字詞或目前網站瀏覽字詞的子系標記的所有項目。例如,這個值可用來查詢的 managed 的屬性 owstaxIdProductCatalogItemCategory 產品目錄網站集合中的內容。這個值無法用來查詢之 managed 的屬性 owstaxidmetadataalltagsinfo 內容。GUID of current site navigation node with a prefix of # — for example, #83e99dcb-7907-4dc9-abc8-b5614a284f1c. This will return all items tagged with the current site navigation term, or children of the current site navigation term. For example, this value can be used to query content of the managed property owstaxIdProductCatalogItemCategory in a Product Catalog Site Collection. This value cannot be used to query the content of the managed property owstaxidmetadataalltagsinfo.
{Term.Name}{Term.Name}
網站瀏覽節點的標籤-例如 Audio。Label of the site navigation node — for example, Audio.
{Term。<屬性>}{Term.<property>}
來自字詞之屬性包的任何屬性,包括自訂屬性。Any property from the property bag of the term, including custom properties.
{TermSet} 或 {TermSet.ID}{TermSet} or {TermSet.ID}
用於目前網站瀏覽之字詞組的 GUID。GUID of the term set used for current site navigation.
{TermSet.Name}{TermSet.Name}
用於目前網站瀏覽之字詞組的標籤。Label of the term set used for current site navigation.

清單與清單項目屬性List and list item properties

查詢變數Query variable 定義Definition
{List}{List}
目前清單的 URL。URL of the current list.
{清單。<屬性>}{List.<property>}
目前清單的任何屬性。Any property of the current list.
{ListItem}{ListItem}
目前清單項目的 URL。URL of the current list item.
{ListItem。<屬性>}{ListItem.<property>}
目前清單項目的任何屬性。Any property of the current list item.

其他屬性Other properties

查詢變數Query variable 定義Definition
{Today + /-<天數的整數值>}{Today+/- <integer value for number of days>}
透過從發出查詢的日期加/減指定天數計算而得的日期。日期格式為 YYYY-MM-DD。例如,此值可以用來查詢 Managed 屬性 LastModifiedTime 的內容。A date calculated by adding/subtracting the specified number of days to/from the date when the query is issued. Date format is YYYY-MM-DD. For example, this value can be used to query content of the managed property LastModifiedTime.
{SearchBoxQuery}{SearchBoxQuery}
在頁面的搜尋方塊中輸入的查詢值。The query value entered into a search box on a page.
{CurrentDisplayLanguage}{CurrentDisplayLanguage}
以 MUI 為根據且格式為 ll-cc 的目前顯示語言。The current display language based on MUI in ll-cc format.
{CurrentDisplayLCID}{CurrentDisplayLCID}
以 MUI 為根據且格式為 ll-cc 之目前顯示語言的數值。Numeric value of the current display language based on MUI in ll-cc format.

處理值中間的空格Dealing with spaces in values

搜尋查詢會使用空白字元,將使用者所發出的查詢值 Token 化。將查詢變數展開為包含空格的值時,完整的值會以雙引號括起來。例如,針對 author:{User} 的查詢,展開的值會變成 author:"John Smith"。Search queries use the space character to tokenize query values issued by users. When a query variable is expanded to a value that contains a space, the complete value is enclosed in double quotations. For example, for the query author:{User}, the expanded value becomes author:"John Smith".

如果您不想要與雙不要加引號括住值 — 例如,當串連多個值-您可以使用逸出字元查詢變數中。例如: customProperty:"{\User.Name};{\User.ZipCode}"會變成 customProperty:"John Smith; 98109"。If you don't want the value to be enclosed with double quotations — for example, when concatenating multiple values — you can use the escape character in the query variable. For example: customProperty:"{\User.Name};{\User.ZipCode}" would become customProperty:"John Smith;98109".

含有多個值的查詢變數Query variables with multiple values

某些查詢變數可能會傳回多個值。必須使用下列語法會傳回多個值的查詢變數,如: {|ManagedProperty: {QueryVariable}}。所有查詢變數值都會都結合使用的位元運算 OR 作業。例如,假設您有字詞組用來分類利息的使用者。所有使用者都已具有一或多個興趣使用使用者設定檔服務應用程式中的多重值屬性 Sps-interests。若要發出查詢之目前使用者的興趣任何,無法使用下列語法: {| owstaxIdMetadataAllTagsInfo: {User.SPS 興趣}}。如果目前的使用者已有兩個興趣 — 橄欖球形 (#0f95d1fdf-781f-42f4-99f9-c656c1341b2e) 和籃球 (#0c2cff933-9377-4692-aa98-ce59768aa38b) — 該查詢會轉換至(owstaxIdMetadataAllTagsInfo: #0f95d1fdf-781f-42f4-99f9-c656c1341b2e) OR (owstaxIdMetadataAllTagsInfo: #0c2cff933-9377-4692-aa98-ce59768aa38b)Some query variables may return multiple values. For query variables that return multiple values, the following syntax must be used: {|ManagedProperty:{QueryVariable}}. All the query variable values will be combined by using the bitwise OR operation. For example, say that you have a term set that is used to categorized interest of users. All users are configured to have one or more interests using the multi-value property SPS-Interests in the User Profile Service Application. To issue a query for any of the interests of the current user, the following syntax could be used: {|owstaxIdMetadataAllTagsInfo:{User.SPS-Interests}}. If the current user is configured to have two interests — football (#0f95d1fdf-781f-42f4-99f9-c656c1341b2e) and basketball (#0c2cff933-9377-4692-aa98-ce59768aa38b) — the query will be transformed to (owstaxIdMetadataAllTagsInfo:#0f95d1fdf-781f-42f4-99f9-c656c1341b2e) OR (owstaxIdMetadataAllTagsInfo:#0c2cff933-9377-4692-aa98-ce59768aa38b) .

使用多個值時有一些限制。只有 OR 運算子 ({|) 支援多個值。不支援 AND 運算子。此外,只有類型為 [受管理的中繼資料] 的欄可以針對多值案例正常運作。可能會使用多個值的其他類型欄 (例如,類型為 [個人]、[群組] 或 [選項] 的欄),即會將字詞展開為分隔的字串。There are some restrictions with using multiple values. Only the OR operator ({|) is supported for multiple values. The AND operator is not supported. Also, only columns of type Managed Metadata work correctly for multiple value cases. Other types of columns that may use multiple values, such as columns of type Person or Group or Choice, the items will be expanded into a delimited string.