search_mode exact and loose_ends both is returning results but not highlighting anything in text
Hi,
the URL is this:
http://mysite.com/search/results?sear...
Results code is this:
{exp:low_search:results limit="30" status="not closed" disable="member_data" orderby="date" sort="desc" paginate="bottom"}
In Low Search settings, "Highlight keywords" is turned on, and "Highlight keywords in title" is NOT marked.
There is word "olimpijski" in the text and multiple words "sportske", but nothing is highlighted.
The query from output profiler is:
SELECT entry_id, collection_id, index_text
FROM ('exp_low_search_indexes')
WHERE 'site_id' IN ('1')
AND (index_text LIKE '%olimpijski%') AND (index_text LIKE '%sport%')
Channel entries contain only 1 text field which we are searching in and that field is also the field which is used for search excerpt so the searched keyphrase could not have been found anywhere else.
Could you explain why it returns results but doesn't highlight anything?
Thanks.
Replies
Low 17 Feb 2014 08:09
Try setting the search mode to 'All' instead of 'Exact', and make sure you're using the {low_search_excerpt} variable in your Results tag.
hrvoje66 17 Feb 2014 08:28
The problem is, we have filters for both "search_mode" and "loose_ends" on our search results page which allow our client to choose for himself what he wants displayed.
We are using {low_search_excerpt} variable which returns text I described above (returns the result but nothing is highlighted).
The text field in which we are searching is marked as "excerpt" in colection settings and it has the highest weight.
If we set "search_mode" to ALL than it finds and highlights the words in that specific result entry but that is not really the solution since we want to allow our client the maximum possible flexibility with manupulation of search results.
Thanks
Low 17 Feb 2014 08:33
Looks like there's a bug in the exact matching. It's not doing that, it's using the All mode instead, by the looks of it. That means that you should only get exact matches back: (index_text LIKE '%olimpijski sport%')
The highlighting does take this into account, so that's why there's nothing highlighted.
To fix the exact matching, in the latest version of Low Search, open up /low_search/filters/lsf.keywords.php and look up line #362, which reads
Below that, add this code:
hrvoje66 17 Feb 2014 08:48
Yes, this fixed it.
Thanks a lot!