Search query variable not working RRS feed

  • Question

  • Apologies for this essay but I felt it may be best if I include all the details in order to describe the issue I'm experiencing.

    I have two site collections in one web app called Library and Store respectively. The library site collection has a content type called Book which is made available to the Store site collection through the content type syndication. The Book content type has a site column in it called Book Author which is of managed metadata type (the term set has a few terms representing authors). The parent content type of the Book is the out of the box Article Page and the Store site collection has custom page layout associated with the Book content type.

    I then add a page and switch its page layout to my custom layout based on the Book content type and on the page, I put a content search web part. I have a managed property called BookAuthor which is mapped to the crawled property pointing at the Book Author field and this is where things start to go awry. The query I use in the content search web part looks something like this:

    ContentType:Book BookAuthor:{Page.Book Author}

    According to the documentation of the query variables and FQL (, this should return items that are of the Book content type where the BookAuthor is the value of the Book Author field on the current page that the content search web part resides on. In this case, my query returns no results. In order to test if it actually works, I manually typed in the value of the author for the BookAuthor property so it looked something like this:

    ContentType:Book BookAuthor:John Doe

    The second query returned the results I expected, but the first one didn't. I've come across a similar problem to  this and previously, I found out that SharePoint had duplicated the Book Author field in the content type such that one was named "Book Author" and the type showing was TaxonomyFIeldTypeMulti while the other one was named "Book Author_0" and the type showing was Note. I used the following powershell script to determine the names of the fields in the content type:

    $site = new-object Microsoft.SharePoint.SPSite("") 
    $web = $site.OpenWeb() 
    $list = $web.Lists["YourList"] 
    $list.Fields | Format-Table Title, InternalName, TypeAsString

    Previously when I encountered this problem, I simply tried both fields and one would always work. For example, I would try BookAuthor:{Book Author} and BookAuthor{Book Author_0} and one of them would work. In this case, I've tried both and none of them seem to yield any results in my query. I noticed that I always seem to get duplicated fields only when I'm using columns of managed metadata type. I know my managed properties work because I can specify manual values and that yields the results I expect, but as soon as I try to use the query variable from the page fields, it doesn't work. Strangely enough, I can use the Title or any other non-managed metadata fields of the page in my query variable (e.g. {Page.Title}) and I can get results that way. I've done index resets and full crawls but nothing seems to fix this. Any help or insight on this would be greatly appreciated as it is driving me nuts!

    Friday, May 9, 2014 1:53 AM