Lucene and Highlighted text font issues

217 Views Asked by At

Im using Lucene HighLighter, with success. Here is my code:

                    StringBuffer sb = new StringBuffer();
        for (int t = 0; t < fields.length; t++) {
            SimpleHTMLFormatter formatter = new SimpleHTMLFormatter(
                    "<span class=\"highlight\">", "</span>");
            Highlighter highlighter = new Highlighter(formatter,
                    new QueryScorer(parser.parse(queryString)));

            if (d.get(fields[t]) != null) {
                hilites = highlighter.getBestFragments(analyzer, fields[t],
                        d.get(fields[t]), 3);
                int l = hilites.length;
                // System.out.println("hilites length: "+l);
                if (l > 0) {

                    for (int x = 0; x < l; x++) {
                        sb.append(hilites[x]).append("...");
                    }

                }
            }

        }

The problem is on my search results/highlighted text, the characters are garbled. Is this due to missing fonts?

Here is my Highlight text:

**on Educational Materials ~ ATS Job Board ""OR~C'C" .. III DUES United States Full... ? SL[I!," Full Memberhsip - Domestic membership is for residents residing in the United States. Dues...**

Notice the funky text!

Any help would be greatly appreciated.

1

There are 1 best solutions below

1
On

The 'Garbled Text Problem' is probably not related to Lucene, but XML encoding. Did you set the 'contentType' to "text/html;charset=UTF-8"?