4

We are building a website on SharePoint 2013 using the new cross site publishing and search features. We want to implement a "Related Items" feature using the Content Search web part in tandem with managed metadata fields that exist across all page content types. Hence content (catalog items) could be tagged with a "Locations" field to describe the content item's geographical relevance.

If we have a catalog item page that is using the Content Search web part (and Content Reuse web parts) to display the main page information is it then possible to add another Content Search web part to the page that uses data from the main query (i.e. the contents of the Location field) to run another search to pull back all other content matching the same Location. In our context the Location field allows multiple values so ideally it would be able to match on multiple items too.

I know this was possible with single value metadata fields in 2010 using the Content Query Web Part but is this functionality replicated in the Content Search Web Part?

I can see that you can match on a tag, but that relies on you hard coding a value in to the web part, we want it to be dynamic based on other values on the page. I can also see that you can use a "Field" value from the "Current Page" as a Property Filter in the Content Search Web Part. My understanding though is that items pulled from Search are not "Fields on the page".

Does anyone know how to implement this feature using the SharePoint 2013 search features? Or provide any links to documentation of this process?

Thanks.

1 Answer 1

2

I've found a way to accomplish this given a situation where the managed property value I need to make the secondary/related CSWP lookup happens to be exposed in the URL of the primary catalog item.

I.e., a People Catalog with a catalog item URL of (/directory/Last, First) --- I want to show activities related to that person (from an Activities Catalog at /activities/Activity Title) on the person's catalog item page.

So in the Activities Catalog I created a site column 'Credit' and populated it with values of 'Last, First' - then on the People Catalog individual item page I went into edit mode, added a CSWP, and leveraged the "value of a token from URL" advanced query parameter to search the Activities list:

(contentclass:sts_listitem OR IsDocument:True) SPSiteUrl:http://authsite.organization.com ListId:6b291282-99e7-4d97-a5ff-activitieslistGUID CreditOWSTEXT:{URLToken.1}

I have not yet found a way to directly pass a value retrieved from one CSWP to another CSWP as a query filter parameter, though my brain sort of expects that capability to be there somewhere, and it might just be a case of my overlooking something obvious or under-documented (or maybe just my glazing over while reading documentation.)

I also have not yet found a good way to work this relationship in reverse. In other words, the Activities Catalog item URLs look like /activities/ActivityTitle so I'm not able to add a second CSWP on an individual activity page and have it query the person, since their name isn't exposed in the URL, and I don't want to add a column to a person which contains the titles of all activities related to them (though I suppose that could work.)

Though the Credit column I created above is a Single Line of Text field, it is populated on the authoring site through an on-modify workflow that copies the value from a lookup field. (In other words, the content manager on the authoring site selects the value from a Lookup field, and a workflow populates the text field with the lookup value.) I did this since it's so much easier to work with text fields in CSWP than lookup fields, though I expect that as I become more capable this might not prove necessary.

If you want to know more about the solution described above, just let me know... happy to discuss. Relating information between lists continues to feel more an art than a science, especially on opposite sides of the search service, and I continue to learn better techniques everyday!

PS - I haven't played much with web API services, but rather than nesting a CSWP in the individual catalog item page, I'd assume if the DOM output produced is solid, you could use client-side JavaScript to read a field value from the rendered CSWP page (based on ID or name or something) and run a subsequent AJAX query against another list to retrieve related values.

Peace and Joy!

1
  • Thanks for the response. I was reading the whole thing and was thinking to myself that actually we could do this in JavaScript and call the Search API manually ourselves. And then you suggested that approach yourself right at the end. I think that is probably the best approach for us. Thanks again. Commented Jan 26, 2014 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.