Hi,
I’m encountering another highlighting issue.
(about the first one “range search and highlighting”, i received no
response. I don’t even know if somebody tried to reproduce and/or if
it’s normal behavior)
about the new issue, an example will be easier for you to reproduce:
I’m filling an index with random data, i try to match for “1” and
then highlight the matched tokens. If it’s matched and not highlighted
i put it in z
It works as expected when there’re 100 entries (replace 500.times by
100.times), in that case z contains empty arrays.
When having 500 entries it doesn’t highlight every matches !
This example has been tested with 0.11.4
(r770 has been tested with the application i first discovered this
issue with)
I would appreciate if you could test and tell me if I’m the only one
having this problem.
TIA
filling
index=Index::Index.new(:path => ‘/tmp/test’)
chars1 = chars2 = chars3 = chars4 = (“a”…“z”).to_a + (“0”…“9”).to_a
chars2.concat(["-", “_”, " “])
chars3 << " "
chars4 << “-”
chars5 = chars6 = (“0”…“9”).to_a
chars6 << “.”
500.times do
z={}
t=”"
1.upto(15+rand(10)) { |i| t << chars4[rand(chars4.size-1)] }
z[:un] = t
t=""
1.upto(40+rand(40)) { |i| t << chars2[rand(chars2.size-1)] }
z[:deux] = t
t=""
1.upto(30+rand(10)) { |i| t << chars4[rand(chars4.size-1)] }
z[:trois] = t
t=""
1.upto(30+rand(10)) { |i| t << chars1[rand(chars1.size-1)] }
z[:quatre] = t
t=""
1.upto(30+rand(10)) { |i| t << chars2[rand(chars2.size-1)] }
z[:cinq] = t
t=""
1.upto(12) { |i| t << chars5[rand(chars5.size-1)] }
z[:six] = t
t=""
1.upto(12) { |i| t << chars6[rand(chars6.size-1)] }
z[:sept] = t
t=""
1.upto(12) { |i| t << chars6[rand(chars6.size-1)] }
z[:huit] = t
t=""
1.upto(24+rand(24)) { |i| t << chars3[rand(chars3.size-1)] }
z[:neuf] = t
t=""
1.upto(100+rand(100)) { |i| t << chars2[rand(chars2.size-1)] }
z[:dix] = t
index << z
end
#testing
q=“1”
z={}
index.search_each(q,:limit => :all) do |id,score|
for b in [:un, :deux, :trois, :quatre, :cinq, :six, :sept, :huit, :neuf,
:dix]
z[b]=[] if not z[b]
z[b] << id.to_s + " : " + index.highlight(q,id,:field => b, :pre_tag =>
“”, :post_tag => “”, :num_excerpts => :all, :excerpt_length =>
:all).join(" | “) if index[id][b].match(/1/) and
index.highlight(q,id,:field => b, :pre_tag => “”, :post_tag =>
“”, :num_excerpts => :all, :excerpt_length => :all) and not
index.highlight(q,id,:field => b, :pre_tag => “”, :post_tag =>
“”, :num_excerpts => :all, :excerpt_length => :all).join(” |
“).match(//)
end
end
z
index.search(”*",:limit => :all).total_hits