Direct Answer - Field Mappings

Hello,

I’ve recently added a featured snippet direct answer card to my client’s Search experience but there are a couple of tweaks I’m struggling to make. This direct answer card returns the “Answer” field from FAQ entities.

Firstly, how can I update my direct answer card so that the “Name” field from the entity is always returned as the title? If you see the screenshot below you’ll see only the “Answer” comes through and the client wants the “Name” to show too.

Secondly, how can I ensure the “View details” link shows below the snippet? We’ve loaded URLs into the “Primary CTA” field on the FAQ entities so that’s the field we want to use to return a clickable URL. Thanks.

Hi Scott,

To answer these questions, you should look at the card that is being used (documentsearch-standard by default, which you can find in the theme). If you want to customize the card, you’ll need to add a new direct answer card using this one as a template, and then you can customize it just as you would any other card.

Feel free to take a look at the Hitchhikers search as an example of using the documentsearch-standard card:

For the view details link, the documentsearch-standard card shows the entity name and link at the bottom: “Read more about [[name]]”. In the card template.hbs file, you can see the property for the link URL is viewDetailsLink (the href) and the text is viewDetailsText (between the <a> tags).

The component.js file sets these properties:

  • viewDetailsText uses the name field of the related item.
  • viewDetailsLink uses the website or landingPageUrl field of the related item.

To make this work for FAQs, you may need to set viewDetailsText to use the question field and viewDetailsLink to use the primary CTA URL field in your forked card (don’t forget to set the card in the config > faqs.json file).

For the FAQ name as the title, you can see there’s already a title section in the template.hbs file that’s mapped to the value property. In the component.js file, this is mapped to answer.value. To use the FAQ name, change this to value: relatedItemData.fieldValues.question,

Hope this helps!