(12/02/22 7:53), Nitin Arora wrote:
Hi,I'm using SOLR and Lucene in my application for search. I'm facing an issue of highlighting using FastVectorHighlighter not working when I use PayloadTermQueries as clauses of a BooleanQuery. After Debugging I found that In DefaultSolrHighlighter.Java, fvh.getFieldQuery does not return any term in the termMap. FastVectorHighlighter fvh = new FastVectorHighlighter( // FVH cannot process hl.usePhraseHighlighter parameter per-field basis params.getBool( HighlightParams.USE_PHRASE_HIGHLIGHTER, true ), // FVH cannot process hl.requireFieldMatch parameter per-field basis params.getBool( HighlightParams.FIELD_MATCH, false ) ); FieldQuery fieldQuery = fvh.getFieldQuery( query ); The reason of empty termmap is, PayloadTermQuery is discarded while constructing the FieldQuery. void flatten( Query sourceQuery, Collection<Query> flatQueries ){ if( sourceQuery instanceof BooleanQuery ){ BooleanQuery bq = (BooleanQuery)sourceQuery; for( BooleanClause clause : bq.getClauses() ){ if( !clause.isProhibited() ) flatten( clause.getQuery(), flatQueries ); } } else if( sourceQuery instanceof DisjunctionMaxQuery ){ DisjunctionMaxQuery dmq = (DisjunctionMaxQuery)sourceQuery; for( Query query : dmq ){ flatten( query, flatQueries ); } } else if( sourceQuery instanceof TermQuery ){ if( !flatQueries.contains( sourceQuery ) ) flatQueries.add( sourceQuery ); } else if( sourceQuery instanceof PhraseQuery ){ if( !flatQueries.contains( sourceQuery ) ){ PhraseQuery pq = (PhraseQuery)sourceQuery; if( pq.getTerms().length> 1 ) flatQueries.add( pq ); else if( pq.getTerms().length == 1 ){ flatQueries.add( new TermQuery( pq.getTerms()[0] ) ); } } } // else discard queries } What is the best way to get highlighting working with Payload Term Queries?
Hi Nitin, Thank you for reporting this problem! Your assumption is correct. FVH discards PayloadTermQueries in flatten() method. Though I'm not familiar with SpanQueries so much, but looks like SpanTermQuery which is the super class of PayloadTermQuery, has getTerm() method. Do you think if flatten() can recognize SpanTermQuery and then add the term to flatQueries, it solves your problem? If so, please open a jira ticket. And if you can, attach a patch would help a lot! koji -- Query Log Visualizer for Apache Solr http://soleami.com/
