Hi there, I have a question on using the Highlighter.
I'm using Lucene in a web application that allows you to search the catalogue of a library. The idea is to highlight, in the results, the terms entered by the user. I'm using a Highlighter with a NullFragmenter because I want the whole field highlighted (for each field the user searched in). The catalogue is indexed with a StandardAnalyzer on each field. Highlighting a field from a result I do like this : QueryScorer scorer = new QueryScorer ( theQuery, searcher.getIndexReader ( ) , fieldName ) ; Highlighter highlighter = new Highlighter ( new SimpleHTMLFormatter ( "<span style=\"border-style:solid;\">" , "</span>" ) , scorer ) ; highlighter. setTextFragmenter ( new NullFragmenter ( ) ) ; highlightedFieldContent = highlighter. getBestFragment ( analyzer , fieldName , originalFieldContent ) ; This works all very well, except for phrase queries. The spans of the phrase queries as such are not highlighted and instead, each of the terms that is in the phrase query, gets highlighted. I guess this is because the indexed fields have been tokenized, and what-not, by the StandardAnalyzer. Does anyone have a good example about how to implement a highlighting function that works well with phrase queries, too ? thank you very much. Heikki DOELEMAN