[
https://issues.apache.org/jira/browse/LUCENE-7803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Manuel Gellfart closed LUCENE-7803.
-----------------------------------
Resolution: Not A Problem
Okay. I Guess I misused the FunctionScoringQuery.
I now added both the "original" Boolean Queries and the FunctionScoringQueries
wrapping the "original" BooleanQuery to another Top Level Boolean Query instead
of just adding the FunctionScoringQueries.
Now the boosting and the highlighting works correctly. I will close this issue.
> Problem using FunctionScoreQuery and Highlighting
> -------------------------------------------------
>
> Key: LUCENE-7803
> URL: https://issues.apache.org/jira/browse/LUCENE-7803
> Project: Lucene - Core
> Issue Type: Bug
> Components: core/query/scoring, modules/highlighter
> Affects Versions: 6.5
> Reporter: Manuel Gellfart
> Priority: Minor
>
> Hey,
> I just updated my Lucene to 6.5.0 and tried to get rid of the now deprecated
> index-time field boosts.
> So I did the suggested fix in the deprecation message and added
> FloatDocValues to each Document holding the Boosts for each indexed field.
> In my current Search Implementation there is one BooleanQuery per Field
> containing three BoostQueries. To apply the field boosts from my DocValues I
> wrapped each BooleanQuery inside a FunctionScoreQuery like this:
> {code:java|borderStyle=solid}
> BooleanQuery booleanQuery;
> ...
> new FunctionScoreQuery(booleanQuery,
> DoubleValuesSource.fromFloatField(fieldName));
> {code}
> So far it works as expected but I realized that my Highlighting is not
> working anymore.
> For Highlighting I use the following Snippet:
> {code:title=MyHighlighting.java|borderStyle=solid}
> public static String[] getFragmentsWithHighlightedTerms(Analyzer
> analyzer, Query query, String fieldName, String fieldContents) {
> QueryScorer scorer = new QueryScorer(query);
> Fragmenter fragmenter = new SimpleFragmenter(80);
> Highlighter highlighter = new Highlighter(new EscapeHtmlFormatter(),
> scorer);
> highlighter.setTextFragmenter(fragmenter);
> highlighter.setMaxDocCharsToAnalyze(Integer.MAX_VALUE);
> TextFragment[] fragments;
> try {
> TokenStream tokenStream = analyzer.tokenStream(fieldName,
> fieldContents);
> fragments = highlighter.getBestTextFragments(tokenStream,
> fieldContents, true, 1);
> } catch (InvalidTokenOffsetsException e) {
> throw WrappedException.wrap(e);
> }
> return formatFragments(fragments);
> }
> }
> {code}
> When I remove the FunctionScorerQuery wrapped around my BooleanQueries the
> Highlighting is perfectly fine again. Am I missing something here or is this
> a bug?
> PS: This is my first post here. I hope I did everything right ;)
> Cheers
> Manu
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]