How can I insert a computed index field in Solr as a rendering variant, I tried creating a field variant with the same name but it didn't work.

  • Is there any way I can bind the computed field to data attributes of a rendering variant Feb 2, 2023 at 21:56

1 Answer 1


There is no out-of-the-box variant definition item to fetch content from an index. But you can create it yourself.

One way would be to use NVelocity. A nice blog post on how to extend that can be found here: https://michaellwest.blogspot.com/2017/04/custom-rendering-variant-token-tool-for-sxa.html

Create your processor, add it to the getVelocityTemplateRenderers pipeline and use it in a template. The process method in the processor can get the item as parameter - with this information you can fetch the field from your index and return the value.

ps: you can make it more generic if you also pass the field name from the template to the processor

UPDATE: in SXA 1.9 a new pipeline was added called processSearchItems that you can use if you are using the ootb Search functionality. The ootb processor in that pipeline will cast the item to a SearchItem which includes an empty object. You could add a processor to that pipeline that fills that object with the needed data. The data from that object can be rendered with the Model variant (or Model iterator as from 1.9).

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.