Why is our customized AnswerContent widget receiving unexpected HTML tags in plaintext fields?
Oracle Service Cloud with Knowledge Advanced (KA), any version, end-user pages
A plaintext field is having <a name="__highlight">...</a> and/or <span></span> tags added to it when accessed from search results.
When an article is accessed by clicking on it in search results, search highlighting can add formatting tags to anything that matches the search query and is in an indexed field.
A customization may rely on a certain field being received exactly as written in the article content XML. For example: A certain schema attribute holds the name of an Intelligent Advisor model. Due to a customization, when that field is reached in the end-user pages, the AnswerField widget is not called. Instead, the model name is used to build the call to the IA widget using the framework's #rn:php:$value# tag. If the field has had tags added to it from search, then the model name will include them, which will cause IA to return a 404 not found error.
To make sure that the search highlighting tags are not applied to this field, you could:
- Disable full-text search and attribute search for that field. Note that if the text is meaningful, this could alter the position of the article in search results for queries matching that text. This can be achieved by editing the schema attribute and unchecking "Enable full-text search" and "Enable attribute-level searching." You will need to reindex the knowledge base by running the full KB content update job in Collection Setup for this change to take effect.
- Disable search highlighting. Highlighting can be disabled entirely via the Search Configuration tool in Agent Desktop. You will need to reindex the knowledge base by running the full KB content update job in Collection Setup for this change to take effect.
- Programmatically remove unneeded tags. PHP has the strip_tags function available if you want to remove all tags from the string.
- Include text matching the query of interest higher in the content so that the highlighting anchor tag is added there. This would require special attention from authors.
For each of the options above, there are different drawbacks. Review the Documentation for Knowledge Advanced for more information on the KA-specific functionality. Documentation for framework tags can be found by navigating to your site's Customer Portal administration area, selecting the Framework dropdown, then Page Tags.