プロジェクト

全般

プロフィール

Vote #68281

未完了

Highlighting in search results is case sensitive for cyrillic pattern

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Search engine_16
対象バージョン:
-
開始日:
2010/10/01
期日:
進捗率:

50%

予定工数:
category_id:
16
version_id:
0
issue_org_id:
6551
author_id:
15554
assigned_to_id:
0
comments:
7
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
21
ステータス-->[New]

説明

I am sorry for my persistence, I have published the same problem on forum, but still have no response from there...

When I search any pattern in english everything works fine - highlighting in search results is case insensitive. If I try to search pattern in russian I have case insensitive search output, but highlighting my pattern in that results is case sensitive.

For example, if I try to search "ам" (all in lowercase) pattern I will see the next:

!with_highlighting.png! - all letter in search output are lowercase and highlighting work fine

!without_highlighting.png! - but if it is one letter or more is uppercase, highlighting doesn't appear.

In source code of search results page this tag ам exist for first image and does not exists for the second.

I use MySQL 5.1.41 database with utf8_general_ci encoding and apache + passenger on Ubuntu 10.04, rails-2.3.5, ruby 1.8.6. Please help me to remove this little issue. Thanks!


journals

--------------------------------------------------------------------------------
Thank you very much!
--------------------------------------------------------------------------------
Sorry but the underlying issue seems to be a Ruby Regexp one as Redmine code in @SearchHelper#highlight_tokens@ seems fairly safe in the way it handles case : source:trunk/app/helpers/search_helper.rb#L22.

Added #4050 as blocker.
--------------------------------------------------------------------------------
In other words, the problem will be solved only when the Ruby Regexp will be fixed?
--------------------------------------------------------------------------------
That's what I think, yes.
--------------------------------------------------------------------------------
Actually, I made a fix

<pre>
module SearchHelper
def highlight_tokens(text, tokens)
return text unless text && tokens && !tokens.empty?
re_tokens = tokens.collect {|t| Regexp.escape(t.mb_chars.downcase)}
regexp = Regexp.new "(#{re_tokens.join('|')})"
result = ''
position = 0
text = text.mb_chars
text.downcase.split(regexp).each_with_index do |words, i|
if result.length > 1200
# maximum length of the preview reached
result << '...'
break
end
words = text[position ... (position + words.size)]
position += words.size
if i.even?
result << h(words.length > 100 ? "#{words.slice(0..44)} ... #{words.slice(-45..-1)}" : words)
else
t = (tokens.index(words.downcase) || 0) % 4
result << content_tag('span', h(words), :class => "highlight token-#{t}")
end
end
result
end
end
</pre>
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Confirmed,10134,Case insensitive search is not working with postgres 8.4 and umlauts
blocks,Closed,4050,Ruby 1.9 support

Admin Redmine さんが約4年前に更新

  • カテゴリSearch engine_16 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0