Hi everyone,

I'm excited with Solr. It is exactly what we wanted to write by ourself some time ago. We've already started but now we want to use Solr because of many solved "enterprise" features. I have to say It is great project! I've downloaded Solr 1.3 + SolrJ and have tried to use as embedded one. Everything works fine but one thing is missing - or I can not find it.
In pure Lucene, I can do highlighting after searching. Field values are 
not stored so I fetch these from database and make highlighting.
In Solr, I can't find similar feature. I can do highlighting only on 
STORED fields during query like this:
           SolrQuery query = new SolrQuery()
                   .setQuery(queryString)
                   .addField(IFIELD_SCORE)
                   .addHighlightField(IFIELD_TITLE)
                   .addHighlightField(IFIELD_CONTENT)
                   .addHighlightField(IFIELD_SUBJECT)
                   .setHighlight(true)
                   .setHighlightFragsize(100)
                   .setHighlightSnippets(1)
                   .setHighlightSimplePre("<b>")
                   .setHighlightSimplePost("</b>");
           QueryResponse response = solrServer.query(query);
Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
If the fields is NOT STORED, highlighting does not work (it is logical 
but there is no way to provide field values for highlighting)
But I want to do something like this (I've used this in pure Lucene):

   Query queryRewrited = query.rewrite(indexSearcher.getIndexReader());
   QueryScorer framgmentScorer = new QueryScorer(queryRewrited);
   SimpleHTMLEncoder simpleHTMLEncoder = new SimpleHTMLEncoder();
SimpleHTMLFormatter simpleHTMLFormatter = new SimpleHTMLFormatter("<span class='highlight'>", "</span>"); Highlighter highlighter = new Highlighter(simpleHTMLFormatter, simpleHTMLEncoder, framgmentScorer);
   highlighter.setTextFragmenter(new NullFragmenter());
...
private String doHighlight(String content, String fieldId, Highlighter highlighter) {
       String hlContent = content;
hlContent = highlighter.getBestFragment(analyzer, fieldId, hlContent);
       return hlContent;
   }

Is there any way to do this? I've googled it for last two nights... I haven't found way in to retreive
   1) rewrited Query
   2) QueryScorer
   3) Solr field type and their Analyzers (both, index+query)

Thanks in advance.

Petr




Reply via email to