1

I've added a Search Content Source for my BDC application, and results are populating correctly. So far, so good! I don't really like the way the results get displayed, though.

Problem 1: Result Titles

The title of the result is always the file name of the profile page. Obviously, since every item of a type has the same profile page, this isn't really helpful. Is there a way for me to change what's displayed there? Ideally, it would be a combination of a few different fields on the item, such as First Name + Last Name.

Using the screenshot below as an example, I'd like to change the link that says Customer_1.aspx, right above the content snippet.

Example SharePoint search result

Problem 2: Text snippets

Is there a way for me to force the Search result to display certain fields from the item? In this example, for a contact search, maybe I would want to show their phone number and email address right away, to save the user from having to click through and wait for the profile page to load just to get basic contact info.

Update: Result Type

I've been researching this most of the day, and I've learned that I need to create a Result Type for my external content type. Once I have that, I can create custom display templates. I've tried this a bunch of times, but I still can't seem to get it working.

I've created a managed property on one of the columns (a non-null integer that is only on this record type), but I've not found a property match setting that will work. Any suggestions?

enter image description here

1

The solution is to create a new Display Template that includes the BCS fields as Managed Properties. You have to add the Managed Properties in the Search Service Application under Search Schema, and then do a full crawl.

Copy an existing display template and then add your managed properties and rendering logic so it looks the way you want.

You can follow this guide: http://www.ableblue.com/blog/archive/2013/06/05/introduction-to-sharepoint-2013-display-templates/ For debugging: http://www.ableblue.com/blog/archive/2014/03/01/create-a-diagnostic-display-template/

For the Result Type you have a couple choices, probably the easiest is to create a result source. You can create a result source that includes just the entities from BCS. The results will be associated with the ContentType from your BCS Entity. In my case the BCSEntity is "Customer" (because I have a Customer Entity in my BCS Model). This way I create a Result Type rule and apply it to my Result Source. It looks like yours will be something like ASICustomer.

Another alternative is to create a rule like ASICustomerNumber contains "1,2,3,4,5,6,7,8,9,0"

  • Okay, I need to try this out, but I think this looks like it might be the right approach to what I'm trying to do. Thanks! I'll report back in a bit. – Ben Wyatt Mar 21 '14 at 14:06
  • Also note, you don't need to use the default Profile Page, you can create your own anywhere you'd like. – Matthew McDermott Mar 21 '14 at 15:28
  • I've configured a Result Source, and the query tests correctly. I've configured the Result Type to match all content from that source, but it isn't displaying with the template assigned to the Result Type. Any thoughts? (I'm starting to wonder if I don't have a separate, second question at this point.) – Ben Wyatt Mar 24 '14 at 17:12
  • You can force it by choosing only your result type in the web part, but I would double check your rule. – Matthew McDermott Mar 25 '14 at 12:51
  • It works fine when I force it to use that display template. I've created and re-created the rule a couple times, but I can't figure out why it's not working. I am running the RTM build right now, though, and I've seen reports there may have been issues there. I'm updating to SP1 today to see if it helps. You answered my original question brilliantly, though, so I'm marking your answer as accepted. If I still have issues with the rule, I'll ask a new question for that, since it's really a separate issue at this point. – Ben Wyatt Mar 25 '14 at 14:02
0

Solution to problem 1 (and maybe 2 too)

You have to configure the External Content Type Profile Page Host To do it you could follow this guide http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/04/15/how-to-create-a-bcs-profile-page-in-sharepoint-2010.aspx

I hope that this can help you.

  • That's just the part you have to do in order to have them show up in results at all. It doesn't actually impact how they're displayed. – Ben Wyatt Mar 20 '14 at 14:00
  • The OP problem #1 is about result type display template design, fields and layout for use by search results webpart rendering. This answer is nothing to do with that. – JohnC Oct 15 '15 at 16:35
0

RE: the OP question #1,"How do you display a managed property in place of the Title field (profile page name for BDC ECTs) in the display template?" (paraphrased).

Based on reading Matthew's and Bella Engen's various blog posts on this topic I see two possible solutions. I have not yet implemented either one.

  1. Modify Item_CommonItem_Body.html to replace the Title field output. This common display template is called from your display template by the line _#=ctx.RenderBody(ctx)=#_
  2. In-line the code from Item_CommonItem_Body.html into your display template replacing the line _#=ctx.RenderBody(ctx)=#_

For (1), in Item_CommonItem_Body.html modify the line var titleHtml = String.format(...); to output the desired managed property. Of course this affects many display templates in the search centre. This may not be what you want.

For (2), if you have multiple result types thus multiple item display templates you will have to in-line the code multiple times.

Neither of these is a great solution.

Refer to Matthew's blog starting from Introduction to SharePoint 2013 Display Templates and Bella's blog series How to change the way search results are displayed in SharePoint Server 2013

0

RE: the OP question #1 redux, I did more research and found what is likely the preferred solution for 80% of cases. I left my other answer in case the details are useful for the other 20% of casses.

To recap, "How do you display a managed property in place of the Title field (profile page name for BDC ECTs) in the display template?" (paraphrased).

Answer: For BDC / search scenario, map the managed property Title to the crawled property corresponding to the desired entity field.

  • Start by browsing to your search service application
  • Open Search Schema > Managed Properties
  • Filter to properties that contain "Title"
  • Edit the "Title" property

enter image description here

  • Add mapping to the required crawl property(ies)

If you need a crawled property for an aggregate of entity fields, instead create a composite field on the entity because only a single crawled property value will be mapped.

enter image description here

  • Recrawl
  • Recrawl again

I found that the managed property and search results (display template) did not render the correct value from the crawled property until after a couple of crawls or a few hours later. Not sure why.

Your Answer

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

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