Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:30:53+00:00 2026-05-29T12:30:53+00:00

I need to customize Solr highlighting prefix and suffix like this: <span class=highlight>text</span> instead

  • 0

I need to customize Solr highlighting prefix and suffix like this:

<span class="highlight">text</span>

instead of the default

<em>text</em>

That’s why I’m using this configuration within the solrconfig.xml for the HighlightComponent:

<searchComponent class="solr.HighlightComponent" name="highlight">
    <highlighting>
        <fragmentsBuilder name="simple" default="true" class="solr.highlight.SimpleFragmentsBuilder">
            <lst name="defaults">
                <str name="hl.tag.pre"><![CDATA[<span class="highlight">]]></str>
                <str name="hl.tag.post"><![CDATA[</span>]]></str>
            </lst>
        </fragmentsBuilder>
    </highlighting>
</searchComponent>

The following are the default parameters for my standard request handler:

<requestHandler name="standard" class="solr.SearchHandler" default="true">
    <lst name="defaults">
        <str name="hl">true</str>
        <str name="hl.fl">body,title</str>
        <str name="hl.useFastVectorHighlighter">true</str>
    </lst>
</requestHandler>

When I search for the text word I do get the text word highlighted, but not always using the prefix and suffix I configured:

<lst name="highlighting">
    <lst name="document_1">
        <arr name="body">
            <str>my <em>text</em> highlighted</str>
        </arr>
        <arr name="title">
            <str>my <span class="highlight">text</span> highlighted</str>
        </arr>
    </lst>
</lst>

Does anybody know why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:30:54+00:00Added an answer on May 29, 2026 at 12:30 pm

    I am guessing you are seeing this behavior behavior because you only have the prefix and suffix defined for the SimpleFragmentsBuilder and the other highlights are coming from another fragment builder.

    I am using a custom prefix and suffix for my highlighting and I set this value in the formatter section of the highlighting section of the solrconfig.xml and have not had any issues as it will apply to all fragment builders.

    So maybe try the following:

     <highlighting>
       <fragmentsBuilder name="simple" default="true"
              class="solr.highlight.SimpleFragmentsBuilder"/>
       <!-- Configure the standard formatter -->
       <formatter name="html" class="org.apache.solr.highlight.HtmlFormatter"
            default="true">
         <lst name="defaults">
           <str name="hl.simple.pre"><![CDATA[<span class="highlight">]]></str>
           <str name="hl.simple.post"><![CDATA[</span>]]></str>
         </lst>
      </formatter>
     </highlighting>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im writing a Soulver-like application with html+js. I need to customize text from input(highlight).
I have tons of ajax components on this booking engine. I need to customize
I was implementing an iPad application. For this I need to customize the UIImagePickerController,
i need to customize the page that user sees at url: user/%user/orders/%uc_order i tried
That's a question really similar to this previous post of mine. I need to
I want to customize my ExpandableList. My issue is that I need a button
I need to customize the layout for the Like box, the problem i am
I need to customize the normal TCP implementation so that I can implement and
I need to customize the default message composer as at To: I need to
I need to customize the validation message style. The way I am approaching this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.