# Highlighting and range queries

**URL:** <https://www.ruby-forum.com/t/highlighting-and-range-queries/107069>\
**Category:** Ferret\
**Created:** [June 17, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/highlighting-and-range-queries/107069 "2007-06-17T17:41:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 17, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/highlighting-and-range-queries/107069/1 "2007-06-17T17:41:39Z")

</div>

Hi there,

Is highlighting for range queries supposed to work ?  
It doesn’t work here.

here is an non-working example: (highlighting works when q=“test:2007\*”)

require ‘ferret’  
include Ferret

index = Index::Index.new()  
#index.field\_infos.add\_field(:test, :store =\> :yes, :index =\>  
:untokenized)

i=1  
for a in [“20070505”, “20071230”, “20060920”, “20081111”]  
index \<\< {:id =\> i, :test =\> a}  
i+=1  
end

for q in [ ‘test:( \>= 20070101)’, ‘test:2007\*’,  
Ferret::Search::RangeQuery.new(:test, :\>= =\> “20070101”) ]  
index.search\_each(q) do |id, score|  
puts “Document #{index[id][:test]} found with a score of #{score}”  
highlights = index.highlight(q, id, :field =\> :test, :pre\_tag =\>  
“\033[36m”, :post\_tag =\> “\033[m”)  
puts highlights  
end  
puts “------”  
end

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 20, 2007, 11:27am UTC](https://www.ruby-forum.com/t/highlighting-and-range-queries/107069/2 "2007-06-20T11:27:58Z")

</div>

On Sun, Jun 17, 2007 at 05:40:48PM +0200, removed\_email\_address@domain.invalid wrote:

> Hi there,
> 
> Is highlighting for range queries supposed to work ?  
> It doesn’t work here.

Your test doesn’t work for me, too - looks like highlighting is just not  
yet implemented for RangeQueries…

Jens

–  
Jens Krämer  
webit! Gesellschaft für neue Medien mbH  
Schnorrstraße 76 | 01069 Dresden  
Telefon +49 351 46766-0 | Telefax +49 351 46766-66  
removed\_email\_address@domain.invalid | [www.webit.de](http://www.webit.de)

Amtsgericht Dresden | HRB 15422  
GF Sven Haubold, Hagen Malessa
