0

I have a Drupal 7 site using the Search API and Search API Apache SOLR modules to provide search functionality to site visitors.

I'm running Apache SOLR 4.10.2 within my development Vagrant VM environment, and search results are returned for both stemmed and unstemmed terms which is great:


Example search term: "car"

Apache SOLR returns nodes with fields containing the text "car" and "cars"


The problem is, when Apache Solr returns nodes containing the stemmed term "cars", no highlighted excerpts are returned. However results containing the exact term "car" are returned with a hightlighted excerpt as expected.

After extensive searching I found this blog post which contains instructions on how to enable stemming for highlighted excerpts, but no luck.

Here is the excerpt of my schema.xml config file as per the instructions in the blog post:

<!--  Setup simple analysis for spell checking -->

 <fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100">
   <analyzer>
     <tokenizer class="solr.StandardTokenizerFactory" />
     <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
     <filter class="solr.LengthFilterFactory" min="4" max="20" />
     <filter class="solr.LowerCaseFilterFactory" />
     <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
     <filter class="solr.PorterStemFilterFactory"/>
   </analyzer>
 </fieldType>

I have restarted my VM and cleared and reindexed all the nodes, but still no dice.

Has anyone else had this issue before?

Thanks in advance!

2 Answers 2

2

I'm guessing that you, like me, had the "Highlight" filter enabled, which you shouldn't actually do for Solr. I found this nugget of info here:

https://www.drupal.org/node/2358065#comment-9319765

Though Solr returns the excerpt, that processor removes it if there's not an exact match.

1
  • awesome, thanks! will give this a go and post results Aug 15, 2016 at 11:41
0

In case someone using Drupal 8 sees this question (as I did), the advice to turn off the Highlight filter, which was correct for Drupal 7, is not the solution for Drupal 8. Instead:

  • Edit your index at admin/config/search/search-api
  • At the Processors tab, select the Highlight checkbox
  • In the Highlight tab at the bottom of the page under Processor settings, select Create excerpt
  • Save
  • Edit your Solr Server at admin/config/search/search-api
  • Open the ADVANCED section near the bottom of the page
  • Select Retrieve result data from Solr and Retrieve highlighted snippets
  • Save

Now you'll get highlighted snippets for stemmed words. No need to reindex.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.