Wednesday, 3 September 2014

SharePoint Search query based on List content type and Column values

I have two lists which are using two different content types. Each list having some columns. I have to get the data based on some values in the list.

List 1 using: MyContentTypeName1
-Column Name: MyColumnNameFromMyContentTypeName1
-Managed property of the MyColumnNameFromMyContentTypeName1: owstaxIdMyColumnNameFromMyContentTypeName1

List 2 using: MyContentTypeName2
-Column Name: MyColumnName1FromMyContentTypeName2,MyColumnName2FromMyContentTypeName2
-Managed property of the MyColumnName1FromMyContentTypeName2: owstaxIdMyColumnName1FromMyContentTypeName2
-Managed property of the MyColumnName2FromMyContentTypeName2: owstaxIdMyColumnName2FromMyContentTypeName2

My Query is:

{searchTerms?} (contentclass:sts_listitem) path:https://SPO/teams/MySite SPContentType=MyContentTypeName1 owstaxIdMyColumnNameFromMyContentTypeName1:MyColumnValue1 SPContentType=MyContentTypeName2  owstaxIdMyColumnName1FromMyContentTypeName2:AA owstaxIdMyColumnName2FromMyContentTypeName2:BB