Solr highlighting without stop-words for phrases?

2019-05-26 01:49发布

问题:

I am trying to highlight results in Solr and up until now, it's been a struggle of tweaking here and there... My main concern now is that i got the highlighting phrases thing working, but if i search for something like "The World Cup At Brazil: An Unexpected Challenge"

The highlighting field will return: "World Cup Brazil: Unexpected Challenge"

I think this might be due to the stop words (my field is a 'textgen' type, btw). Is there some kind of parameter to run in the query that would return the entire field highlighted as expected? Or will i have to remove the stopwords filter in the textgen?

回答1:

This is definitely due to stopwords. Consider declaring a new fieldtype like textgen, but without the following in it's index or query analyzers:

    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />