Problem/Motivation

When I search for a specific term, it's not highlighted in the search results. I think this happens, because the text array is imploded with new line symbol, but the processor highlight highlights a term when it has white spaces at the beginning and at the end of it.

How to reproduce

If you have a single word in the field, and you search for it, it can't be highlighted.

Proposed resolution

My solution is to implode the array with white space symbol.

Comments

nikolabintev created an issue. See original summary.

nikolabintev’s picture

Project: Search API Solr » Search API
Component: Code » General code
nikolabintev’s picture

StatusFileSize
new552 bytes

Here is my patch.

miroslavbanov’s picture

Component: General code » Plugins
Status: Active » Needs review
miroslavbanov’s picture

Issue summary: View changes

To reproduce:
If you have a single word in the field, and you search for it, it can't be highlighted.

Use case:
Indexing "Link Title" - it's rarely long text. Using just one word is very likely.

Compared to this, Apachesolr parameter 'hl=true' would highlight the text. So this is inconsistent with Apachesolr snippets.

drunken monkey’s picture

StatusFileSize
new794 bytes

Thanks for reporting this problem! Your explanation makes sense. However, Wouldn't it also be possible to just add spaces in addition to the newlines? See the attached patch.
It seems to me there might have been a reason to use newlines, and if so, this should preserve that use.
If this patch works for you, too, I'll commit it.

miroslavbanov’s picture

Status: Needs review » Reviewed & tested by the community

#6 works just as well

nikolabintev’s picture

#6 works for me as well

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

OK, great. Thanks for reviewing!
Committed.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.