0

I'm looking to create a content search web part on the home page of a subsite that displays documents from the current site collection, matching a particular content type. I'd like to return only the documents of value X in one of the content type fields, matching an indexed property of the current subsite.

The query below returns the expected results when I explicitly specify the value of the content type's managed property I want to match (MERC02):

path:"http://sharepoint.mycompany.com/sites/customers" ContentTypeId:0x0100BEE2C15F4211BA4C9E5E4C73DCC48303* CustomerIDTEXT:MERC02

I can see all of the subsite's indexed properties when I query using the Sharepoint Query Search Tool, which returns the target property I want: CustomerIDOWSTEXT = MERC02

So far so good. But I can't figure a way to reference the current subsite's indexed property in the CSWP query. I'm thinking that the following query should work, but it returns no results. Is {site.x} scoped at the site collection level instead of the current web?

path:"http://sharepoint.mycompany.com/sites/customers" ContentTypeId:0x0100BEE2C15F4211BA4C9E5E4C73DCC48303* CustomerIDTEXT:{site.CustomerIDOWSTEXT}

My goal in matching to the site's indexed properties is to avoid using property bags, and surface this info at the STS_Web level by using a custom content type and site columns assigned for the site's web part home page.

Any suggestions out there?

  • Using an out-of-the-box property as an example, how would you match a result set's property to the SiteTitle property of the current web? – Keith Jul 17 '18 at 11:27
  • Try web instead of site. – moe Jul 17 '18 at 11:37
  • I have tried that as well, using CustomerIDTEXT:{Web.CustomerIDOWSTEXT}. No luck there. Web doesn't appear to be a legit query variable, according to the list here: docs.microsoft.com/en-us/sharepoint/technical-reference/… – Keith Jul 17 '18 at 11:42
  • the correct variable is Site only. {Site.<property>} will be scoped to the current SPWeb only, if its site collection it should be {SiteCollection.<property>} – Gautam Sheth Jul 17 '18 at 12:01
  • {Site.<property>} should be it, but I can't match on this. To simplify this, I defined a new query to return all documents in the site collection whose Title="Test" (which returns a few), and then created a new subsite called Test. The CSWP query I tried using site.<property> doesn't match... path:"sharepoint.mycompany.com/sites/customers" ContentTypeId:0x0101* Title:{site.SiteTitle} Also tried site.Title to no avail. – Keith Jul 17 '18 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.