Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we need enable BoostingQuery with FVH highlighter? #19985

chengpohi opened this issue Aug 13, 2016 · 1 comment


None yet
4 participants
Copy link

commented Aug 13, 2016

I have noticed BoostingQuery with FVH highligher is broken.

See the HighlighterSearchIT testBoostingQueryTermVector and testFastVectorHighlighterPhraseBoost

@AwaitsFix(bugUrl="Broken now that BoostingQuery does not extend BooleanQuery anymore")

This is caused by when use FastVectorHighlighter to highlight, that will query field by:

cache.fieldMatchFieldQuery = new CustomFieldQuery(highlighterContext.query, hitContext.topLevelReader(),true, field.fieldOptions().requireFieldMatch());

but for CustomeFieldQuery not flatten BoostQuery, this will cause fieldQueryies are null.

    void flatten(Query sourceQuery, IndexReader reader, Collection<Query> flatQueries, float boost) throws IOException {
        if (sourceQuery instanceof SpanTermQuery) {
            super.flatten(new TermQuery(((SpanTermQuery) sourceQuery).getTerm()), reader, flatQueries, boost);
        } else if (sourceQuery instanceof ConstantScoreQuery) {
            flatten(((ConstantScoreQuery) sourceQuery).getQuery(), reader, flatQueries, boost);
        } else if (sourceQuery instanceof FunctionScoreQuery) {
            flatten(((FunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries, boost);
        } else if (sourceQuery instanceof MultiPhrasePrefixQuery) {
            flatten(sourceQuery.rewrite(reader), reader, flatQueries, boost);
        } else if (sourceQuery instanceof FiltersFunctionScoreQuery) {
            flatten(((FiltersFunctionScoreQuery) sourceQuery).getSubQuery(), reader, flatQueries, boost);
        } else if (sourceQuery instanceof MultiPhraseQuery) {
            MultiPhraseQuery q = ((MultiPhraseQuery) sourceQuery);
            convertMultiPhraseQuery(0, new int[q.getTermArrays().length], q, q.getTermArrays(), q.getPositions(), reader, flatQueries);
        } else if (sourceQuery instanceof BlendedTermQuery) {
            final BlendedTermQuery blendedTermQuery = (BlendedTermQuery) sourceQuery;
            flatten(blendedTermQuery.rewrite(reader), reader, flatQueries, boost);
        } else if (sourceQuery instanceof ToParentBlockJoinQuery) {
            ToParentBlockJoinQuery blockJoinQuery = (ToParentBlockJoinQuery) sourceQuery;
            flatten(blockJoinQuery.getChildQuery(), reader, flatQueries, boost);
        } else {
            super.flatten(sourceQuery, reader, flatQueries, boost);

I have created a PR to enable it: #19984

Is there anyone can review and give some feedback?


This comment has been minimized.

Copy link

commented Aug 13, 2016

Thank you for noticing this and opening the PR.

Just a small note, there is no need to associate an issue with every PR, we accept PRs without issues as long as the PR clearly describes the issue. There is also no need to create an issue to ask for a review of a PR, if you feel the need, you can do that directly on the PR (usually you do not have to ask, plenty of people get notifications on every issue and PR that is opened).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.