lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felipe Lobo <fel...@goshme.com>
Subject Re: Implement SpanScorer on 2.9 lucene lib!
Date Thu, 01 Oct 2009 14:03:43 GMT
Here's the code:
------------------------------------------------------
Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter(), new
QueryScorer(query));

highlighter.setTextFragmenter(new SimpleFragmenter(999999999));

String fieldName = "Title";

String text = document.getField(fieldName).stringValue();

TokenStream tokenStream = analyzer.tokenStream(fieldName, new
StringReader(text));

String markedResult = highlighter.getBestFragments(tokenStream, text, 3,
"...");
----------------------------------------------------
and when i sysout the markedResult shows this:

"Habeas Corpus <B>HC</B> 100930027253 ES 100930027253"

when i put a shorter number, like 4 characther, it makes the highlight, but
this "100930027253" it don't.

the name is realy TermQueryScorer or is QueryTermScorer(i found that in the
package)??

Thanks.


On Thu, Oct 1, 2009 at 10:44 AM, Mark Miller <markrmiller@gmail.com> wrote:

> Felipe Lobo wrote:
> > Hi, thanks for the answer but it didn't work.
> > I stopped rewriting the query and used the queryscorer but it don't
> > highlight.
> > The  part of the query i'm doing wildcard is the number part, like this:
> > "HC 100930027253"
> > The HC is hightlighted but the numbers aren't:
> > "Habeas Corpus <B>HC</B> 100930027253 ES 100930027253"
> >
> Hmm ... I don't know. Should work. Can you post some code?
> > And of what lib is TermQueryScorer? I check out on lucene javadoc and
> didn't
> > see.
> >
> Its in the same package as the QueryScorer, in the Highlighter contrib.
> > Thanks!
> >
> > On Wed, Sep 30, 2009 at 6:38 PM, Mark Miller <markrmiller@gmail.com>
> wrote:
> >
> >
> >> Felipe Lobo wrote:
> >>
> >>> Hi, i updated my lucene lib to 2.9.0 and i'm trying to instanciate the
> >>> spanscorer but the constructor is protected.
> >>> I looked in the javadoc of lucene and saw 2 subclasses of it
> >>> (PayloadNearQuery.PayloadNearSpanScorer,
> >>> PayloadTermQuery.PayloadTermWeight.PayloadTermSpanScorer).
> >>> Using this classes is the best way of implementing spanscorer??
> >>> I was using queryscorer but after update to the new lib the highlither
> >>> stopped hightlithing my wildcard queries, and i'm rewriting.
> >>>
> >>> Thanks,
> >>>
> >>>
> >> Checkout contrib CHANGES.
> >>
> >> The SpanScorer is now the QueryScorer - if you want to highlight
> >> wildcard queries, you should no longer rewrite on your own.
> >>
> >> If you want the old behavior, use TermQueryScorer instead.
> >>
> >> --
> >> - Mark
> >>
> >> http://www.lucidimagination.com
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> >> For additional commands, e-mail: java-user-help@lucene.apache.org
> >>
> >>
> >>
> >
> >
> >
>
>
> --
> - Mark
>
> http://www.lucidimagination.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Felipe Lobo
www.jusbrasil.com.br

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message