Re: Solr Highlighting not working

2020-11-30 Thread Ajay Sharma
Hi All,

pushing the query to the top.
Does anyone have any idea about it?


On Fri, Nov 27, 2020 at 11:49 AM Ajay Sharma  wrote:

> Hi Community,
>
> This is the first time, I am implementing a solr *highlighting *feature.
> I have read the concept via solr documentation
> Link- https://lucene.apache.org/solr/guide/8_2/highlighting.html
>
> To enable highlighting I just have to add *=true=* *in our solr
> query and got the snippet in the solr response and it is working fine in
> most of the cases.
>
> *But highlighting does not work when synonyms came into action*
>
> *Issue:*
> I am searching leopard (q=leopard) in field title (qf=title)
>
> In our synonym file, we have an entry like below
> *leopard,tenduaa,panther*
>
> and in one document id:123456, field title contains below text:
> title:"Jindal Panther TMT Bars
>
> For the query (q=leopard) , i am getting this document (id:123456) in solr
> response
> I could check that due to synonym document is matched  and I confirmed it
> via Solr UI analysis screen where I put Analyse FieldName= title,  Field
> Value (Index) ="Jindal Panther TMT rebars" and Field Value (Query) =
> leopard and I could see in index chain, token panther getting saved as
> leopard also but in highlighting I don't get any matched token and
> getting below response
>
>
>- highlighting:
>{
>   - 123456: { }
>   }
>
>
>
> I just need the matched synonym token like panther in the above case to be
> returned in solr highlighting response
> I have read and re-read the solr documentation, searched on google gone
> through many articles even checked StackOverflow but could not find a
> solution.
> Any help from community members will be highly appreciated.
>
> Thanks in advance.
>
>
> --
> Regards,
> Ajay Sharma
> Software Engineer, Product-Search,
> IndiaMART InterMESH Ltd
>


-- 
Thanks & Regards,
Ajay Sharma
Software Engineer, Product-Search,
IndiaMART InterMESH Ltd

-- 



Solr Highlighting not working

2020-11-26 Thread Ajay Sharma
Hi Community,

This is the first time, I am implementing a solr *highlighting *feature.
I have read the concept via solr documentation
Link- https://lucene.apache.org/solr/guide/8_2/highlighting.html

To enable highlighting I just have to add *=true=* *in our solr
query and got the snippet in the solr response and it is working fine in
most of the cases.

*But highlighting does not work when synonyms came into action*

*Issue:*
I am searching leopard (q=leopard) in field title (qf=title)

In our synonym file, we have an entry like below
*leopard,tenduaa,panther*

and in one document id:123456, field title contains below text:
title:"Jindal Panther TMT Bars

For the query (q=leopard) , i am getting this document (id:123456) in solr
response
I could check that due to synonym document is matched  and I confirmed it
via Solr UI analysis screen where I put Analyse FieldName= title,  Field
Value (Index) ="Jindal Panther TMT rebars" and Field Value (Query) =
leopard and I could see in index chain, token panther getting saved as
leopard also but in highlighting I don't get any matched token and getting
below response


   - highlighting:
   {
  - 123456: { }
  }



I just need the matched synonym token like panther in the above case to be
returned in solr highlighting response
I have read and re-read the solr documentation, searched on google gone
through many articles even checked StackOverflow but could not find a
solution.
Any help from community members will be highly appreciated.

Thanks in advance.


-- 
Regards,
Ajay Sharma
Software Engineer, Product-Search,
IndiaMART InterMESH Ltd

-- 



Re: Solr Highlighting not working with PayloadTermQueries

2012-02-22 Thread Koji Sekiguchi

(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, CollectionQuery  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/


Solr Highlighting not working with PayloadTermQueries

2012-02-21 Thread Nitin Arora
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, CollectionQuery 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? 

Thanks 
Nitin

--
View this message in context: 
http://lucene.472066.n3.nabble.com/Solr-Highlighting-not-working-with-PayloadTermQueries-tp3765093p3765093.html
Sent from the Solr - User mailing list archive at Nabble.com.