Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Lucene Highlighter along with MultiFieldQueryParser

Im using Lucene Highlighter to highlight the matches that I have found in a Lucene Index. Now, my problem is that If I have to search multiple fields of a document, and I need to display the matching text, then how can I get in which field the hit has occurred?

The code which I am using for the highlighter is basically the second function here

If I do not know in which field the hit has occurred in, then what field do I pass to the function defined above to get the matching fragments?

like image 285
mksh15 Avatar asked Aug 17 '26 13:08

mksh15


1 Answers

You could combine the fields into a single text field and run your highlighter on it.

like image 111
Mikos Avatar answered Aug 19 '26 04:08

Mikos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!