Title: snippet constructor error
Last modified: August 22, 2016

---

# snippet constructor error

 *  [Flyer29](https://wordpress.org/support/users/flyer29/)
 * (@flyer29)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/snippet-constructor-error/)
 * Hi Mikko,
 * impressive plugin, compliments! I’m facing right now a small issue with the plugin
   and I don’t know if I’m making an error air the plugin.
 * I’m using relevanssi on an – till now offline – site to search for terms on a
   page, terms that are loaded via shortcodes. This is working fantastically good!
   I’m using the fuzzy search for all searches and the list of results is working
   perfectly, only the snippets are making some troubles.
 * To give you an example, let us search for Panzanella (which is tasting really
   good by the way). Panzanella will give me the right snippet, exactly centered
   around the keyword. Panza will also work, but as soon as I’m looking for anzanella
   or nzanella … or ella, the result is shown but the snippet always start with 
   the first words of the page, without having the keyword shown in the snippet 
   displayed.
 * This is making me believe in a bug in the way the snippet is constructed. I do
   understand you don’t have a lot of time for all the questions, but if you point
   me in the direction of the file constructing the snippet, I would be glad to 
   look first on my own for an eventual bug.
 * Regards
    Pierre
 * [https://wordpress.org/plugins/relevanssi/](https://wordpress.org/plugins/relevanssi/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Flyer29](https://wordpress.org/support/users/flyer29/)
 * (@flyer29)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/snippet-constructor-error/#post-5357324)
 * So, after some time spent with var_dump, I found a solution working for me (but
   I perhaps destroyed something else). So feel free to still give me a solution
   if you have a better one.
 * in the excerpts-highlights.php file, the mb_stripos function around line 211 
   is looking for $term in $excerpt_slice. Unfortunately, you set just before ‘$
   term = ” $term”‘, so that the new $term has no chance to be found in the $excerpts_slice,
   but only if $terms was the beginning of a word, but not a portion. In my example,
   after adding the space to $term, mb_stripos can’t find ” anzanella” in ” Panzanella”
   but would find ” Panz” in ” Panzanella”. So commenting out the addition of a 
   previous space solved my issue (but perhaps broke something else).
 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/snippet-constructor-error/#post-5357433)
 * It works in this case, but if you don’t have fuzzy search enabled, removing the
   space will cause inaccurate snippets that don’t contain the term searched.
 * Excerpts are something that is due to a rewrite, and this is something I’ll take
   into consideration.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘snippet constructor error’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/snippet-constructor-error/#post-5357433)
 * Status: not resolved