Highlight each query keyword in a different color solr

I want to highlight each query keyword in a solr response with a different color.

Example query = 'first and second'. I want the results to be like this:

query result: first random text and second // end of response. Background "first" should be color 1, and "second" should be color 2.

I tried using hl.fragmentsBuilder

but couldn't get the results to highlight.

+3


source to share


1 answer


in lucene, only FastVectorHighlighter class supports mutil color tag, I don't know how to implement in solr, but it can be done in lucene:

  FragmentsBuilder fragmentsBuilder= new ScoreOrderFragmentsBuilder(BaseFragmentsBuilder.COLORED_PRE_TAGS,BaseFragmentsBuilder.COLORED_POST_TAGS);  

  FastVectorHighlighter fastHighlighter2=new FastVectorHighlighter(true, true, fragListBuilder, fragmentsBuilder);  

      



Maybe this is useful for you!

0


source







All Articles